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.
Reviewed By: shchenz, #powerpc
Differential Revision: https://reviews.llvm.org/D107428
40 lines
1.3 KiB
LLVM
40 lines
1.3 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc -mcpu=pwr8 -mtriple=powerpc64le-unknown-unknown \
|
|
; RUN: -verify-machineinstrs < %s | FileCheck --check-prefix=CHECK-LE %s
|
|
; RUN: llc -mcpu=pwr8 -mtriple=powerpc64-unknown-unknown \
|
|
; RUN: -verify-machineinstrs < %s | FileCheck --check-prefix=CHECK-BE %s
|
|
|
|
define <2 x double> @foo(<4 x i32> %s) {
|
|
; CHECK-LE-LABEL: foo:
|
|
; CHECK-LE: # %bb.0: # %entry
|
|
; CHECK-LE-NEXT: xvcvsxwdp 34, 34
|
|
; CHECK-LE-NEXT: blr
|
|
;
|
|
; CHECK-BE-LABEL: foo:
|
|
; CHECK-BE: # %bb.0: # %entry
|
|
; CHECK-BE-NEXT: xxsldwi 0, 34, 34, 1
|
|
; CHECK-BE-NEXT: xvcvsxwdp 34, 0
|
|
; CHECK-BE-NEXT: blr
|
|
entry:
|
|
%0 = shufflevector <4 x i32> %s, <4 x i32> undef, <2 x i32> <i32 1, i32 3>
|
|
%1 = sitofp <2 x i32> %0 to <2 x double>
|
|
ret <2 x double> %1
|
|
}
|
|
|
|
define <2 x double> @bar(<4 x i32> %s) {
|
|
; CHECK-LE-LABEL: bar:
|
|
; CHECK-LE: # %bb.0: # %entry
|
|
; CHECK-LE-NEXT: xvcvuxwdp 34, 34
|
|
; CHECK-LE-NEXT: blr
|
|
;
|
|
; CHECK-BE-LABEL: bar:
|
|
; CHECK-BE: # %bb.0: # %entry
|
|
; CHECK-BE-NEXT: xxsldwi 0, 34, 34, 1
|
|
; CHECK-BE-NEXT: xvcvuxwdp 34, 0
|
|
; CHECK-BE-NEXT: blr
|
|
entry:
|
|
%0 = shufflevector <4 x i32> %s, <4 x i32> undef, <2 x i32> <i32 1, i32 3>
|
|
%1 = uitofp <2 x i32> %0 to <2 x double>
|
|
ret <2 x double> %1
|
|
}
|