[PPC] Implement vector reverse elements builtins (vec_reve)

This patch corresponds to review https://reviews.llvm.org/D25906.
Committing on behalf of Tony Jiang.

llvm-svn: 285218
This commit is contained in:
Nemanja Ivanovic 2016-10-26 18:25:45 +00:00
parent 0c621fda0d
commit 85a28dcc5d
3 changed files with 132 additions and 0 deletions

View File

@ -15034,6 +15034,77 @@ vec_bperm(vector unsigned __int128 __a, vector unsigned char __b) {
#endif
#endif
/* vec_reve */
static inline __ATTRS_o_ai vector bool char vec_reve(vector bool char __a) {
return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
5, 4, 3, 2, 1, 0);
}
static inline __ATTRS_o_ai vector signed char vec_reve(vector signed char __a) {
return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
5, 4, 3, 2, 1, 0);
}
static inline __ATTRS_o_ai vector unsigned char
vec_reve(vector unsigned char __a) {
return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
5, 4, 3, 2, 1, 0);
}
static inline __ATTRS_o_ai vector bool int vec_reve(vector bool int __a) {
return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
}
static inline __ATTRS_o_ai vector signed int vec_reve(vector signed int __a) {
return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
}
static inline __ATTRS_o_ai vector unsigned int
vec_reve(vector unsigned int __a) {
return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
}
static inline __ATTRS_o_ai vector bool short vec_reve(vector bool short __a) {
return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
}
static inline __ATTRS_o_ai vector signed short
vec_reve(vector signed short __a) {
return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
}
static inline __ATTRS_o_ai vector unsigned short
vec_reve(vector unsigned short __a) {
return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
}
static inline __ATTRS_o_ai vector float vec_reve(vector float __a) {
return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
}
#ifdef __VSX__
static inline __ATTRS_o_ai vector bool long long
vec_reve(vector bool long long __a) {
return __builtin_shufflevector(__a, __a, 1, 0);
}
static inline __ATTRS_o_ai vector signed long long
vec_reve(vector signed long long __a) {
return __builtin_shufflevector(__a, __a, 1, 0);
}
static inline __ATTRS_o_ai vector unsigned long long
vec_reve(vector unsigned long long __a) {
return __builtin_shufflevector(__a, __a, 1, 0);
}
static inline __ATTRS_o_ai vector double vec_reve(vector double __a) {
return __builtin_shufflevector(__a, __a, 1, 0);
}
#endif
#undef __ATTRS_o_ai
#endif /* __ALTIVEC_H */

View File

@ -8996,3 +8996,48 @@ void test7() {
// CHECK: @llvm.ppc.altivec.vcmpgefp.p(i32 2
// CHECK-LE: @llvm.ppc.altivec.vcmpgefp.p(i32 2
}
void test8() {
// CHECK-LABEL: define void @test8
// CHECK-LE-LABEL: define void @test8
res_vbc = vec_reve(vbc);
// CHECK: shufflevector <16 x i8> %{{[0-9]+}}, <16 x i8> %{{[0-9]+}}, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <16 x i8> %{{[0-9]+}}, <16 x i8> %{{[0-9]+}}, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
res_vsc = vec_reve(vsc);
// CHECK: shufflevector <16 x i8> %{{[0-9]+}}, <16 x i8> %{{[0-9]+}}, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <16 x i8> %{{[0-9]+}}, <16 x i8> %{{[0-9]+}}, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
res_vuc = vec_reve(vuc);
// CHECK: shufflevector <16 x i8> %{{[0-9]+}}, <16 x i8> %{{[0-9]+}}, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <16 x i8> %{{[0-9]+}}, <16 x i8> %{{[0-9]+}}, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
res_vbi = vec_reve(vbi);
// CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> %{{[0-9]+}}, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> %{{[0-9]+}}, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
res_vi = vec_reve(vi);
// CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> %{{[0-9]+}}, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> %{{[0-9]+}}, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
res_vui = vec_reve(vui);
// CHECK: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> %{{[0-9]+}}, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> %{{[0-9]+}}, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
res_vbs = vec_reve(vbs);
// CHECK: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
res_vbs = vec_reve(vs);
// CHECK: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
res_vbs = vec_reve(vus);
// CHECK: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <8 x i16> %{{[0-9]+}}, <8 x i16> %{{[0-9]+}}, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
res_vf = vec_reve(vf);
// CHECK: shufflevector <4 x float> %{{[0-9]+}}, <4 x float> %{{[0-9]+}}, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
// CHECK-LE: shufflevector <4 x float> %{{[0-9]+}}, <4 x float> %{{[0-9]+}}, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
}

View File

@ -1080,4 +1080,20 @@ void test1() {
// CHECK: fmul <2 x double>
// CHECK-LE: uitofp <2 x i64> %{{.*}} to <2 x double>
// CHECK-LE: fmul <2 x double>
res_vbll = vec_reve(vbll);
// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> <i32 1, i32 0>
// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> <i32 1, i32 0>
res_vsll = vec_reve(vsll);
// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> <i32 1, i32 0>
// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> <i32 1, i32 0>
res_vull = vec_reve(vull);
// CHECK: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> <i32 1, i32 0>
// CHECK-LE: shufflevector <2 x i64> %{{[0-9]+}}, <2 x i64> %{{[0-9]+}}, <2 x i32> <i32 1, i32 0>
res_vd = vec_reve(vd);
// CHECK: shufflevector <2 x double> %{{[0-9]+}}, <2 x double> %{{[0-9]+}}, <2 x i32> <i32 1, i32 0>
// CHECK-LE: shufflevector <2 x double> %{{[0-9]+}}, <2 x double> %{{[0-9]+}}, <2 x i32> <i32 1, i32 0>
}