This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix shift amount of xxsldwi when performing vector int_to_double
ClosedPublic

Authored by lkail on Aug 4 2021, 12:32 AM.

Details

Summary

POC

// main.c
#include <stdio.h>
#include <altivec.h>
extern vector double foo(vector int s);
int main() {
  vector int s = {0, 1, 0, 4};
  vector double vd;
  vd = foo(s);
  printf("%lf %lf\n", vd[0], vd[1]);
  return 0;
}
// poc.c
vector double foo(vector int s) {
  int x1 = s[1];
  int x3 = s[3];
  double d1 = x1;
  double d3 = x3;
  vector double x = { d1, d3 };
  return x;
}

Compiled with poc.c main.c -mcpu=pwr8 -O3 on BE machine.
Current clang gives

4.000000 1.000000

while xlc gives

1.000000 4.000000

Xlc's output should be correct.

Diff Detail

Event Timeline

lkail created this revision.Aug 4 2021, 12:32 AM
lkail requested review of this revision.Aug 4 2021, 12:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2021, 12:33 AM
lkail edited the summary of this revision. (Show Details)Aug 4 2021, 12:33 AM
lkail edited the summary of this revision. (Show Details)
lkail updated this revision to Diff 363989.Aug 4 2021, 12:47 AM

Add poc's codegen.

lkail updated this revision to Diff 364000.Aug 4 2021, 1:30 AM
shchenz added inline comments.Aug 5 2021, 7:05 PM
llvm/lib/Target/PowerPC/PPCInstrVSX.td
2969

I assume for unsigned, it has the same issue?

lkail added inline comments.Aug 5 2021, 7:13 PM
llvm/lib/Target/PowerPC/PPCInstrVSX.td
2969

Yes, I'll update it.

lkail updated this revision to Diff 364673.Aug 5 2021, 7:15 PM
lkail marked an inline comment as done.
qiucf added inline comments.Aug 5 2021, 7:16 PM
llvm/test/CodeGen/PowerPC/vec_int_to_double_shuffle.ll
1

Pre-commit it or generate git-diff after git-add.

lkail updated this revision to Diff 364682.Aug 5 2021, 8:00 PM

Rebased.

lkail marked an inline comment as done.Aug 5 2021, 8:00 PM
shchenz accepted this revision.Aug 5 2021, 10:27 PM

LGTM. Thanks for fixing this.

This revision is now accepted and ready to land.Aug 5 2021, 10:27 PM