r286205 - [PowerPC] Implement remaining vector comparison builtins.
Tony Jiang via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 7 20:15:46 PST 2016
Author: jtony
Date: Mon Nov 7 22:15:45 2016
New Revision: 286205
URL: http://llvm.org/viewvc/llvm-project?rev=286205&view=rev
Log:
[PowerPC] Implement remaining vector comparison builtins.
vector bool char vec_cmpeq (vector bool char, vector bool char);
vector bool int vec_cmpeq (vector bool int, vector bool int);
vector bool long long vec_cmpeq (vector bool long long, vector bool long lon
vector bool short vec_cmpeq (vector bool short, vector bool short);
Modified:
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c
Modified: cfe/trunk/lib/Headers/altivec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=286205&r1=286204&r2=286205&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Mon Nov 7 22:15:45 2016
@@ -1564,6 +1564,12 @@ vec_cmpeq(vector unsigned char __a, vect
(vector char)__b);
}
+static __inline__ vector bool char __ATTRS_o_ai
+vec_cmpeq(vector bool char __a, vector bool char __b) {
+ return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
+ (vector char)__b);
+}
+
static __inline__ vector bool short __ATTRS_o_ai vec_cmpeq(vector short __a,
vector short __b) {
return (vector bool short)__builtin_altivec_vcmpequh(__a, __b);
@@ -1575,6 +1581,12 @@ vec_cmpeq(vector unsigned short __a, vec
(vector short)__b);
}
+static __inline__ vector bool short __ATTRS_o_ai
+vec_cmpeq(vector bool short __a, vector bool short __b) {
+ return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a,
+ (vector short)__b);
+}
+
static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector int __a,
vector int __b) {
return (vector bool int)__builtin_altivec_vcmpequw(__a, __b);
@@ -1586,6 +1598,12 @@ vec_cmpeq(vector unsigned int __a, vecto
(vector int)__b);
}
+static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector bool int __a,
+ vector bool int __b) {
+ return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a,
+ (vector int)__b);
+}
+
#ifdef __POWER8_VECTOR__
static __inline__ vector bool long long __ATTRS_o_ai
vec_cmpeq(vector signed long long __a, vector signed long long __b) {
@@ -1597,6 +1615,13 @@ vec_cmpeq(vector unsigned long long __a,
return (vector bool long long)__builtin_altivec_vcmpequd(
(vector long long)__a, (vector long long)__b);
}
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpeq(vector bool long long __a, vector bool long long __b) {
+ return (vector bool long long)__builtin_altivec_vcmpequd(
+ (vector long long)__a, (vector long long)__b);
+}
+
#endif
static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
@@ -2298,14 +2323,15 @@ vec_first_match_or_eos_index(vector sign
result if either is zero.
*/
vector bool char __tmp1 = vec_cmpeq(__a, __b);
- vector bool char __tmp2 = __tmp1 | vec_cmpeq(__tmp1, __a) |
- vec_cmpeq(__tmp1, __b);
+ vector bool char __tmp2 = __tmp1 |
+ vec_cmpeq((vector signed char)__tmp1, __a) |
+ vec_cmpeq((vector signed char)__tmp1, __b);
vector unsigned long long __res =
#ifdef __LITTLE_ENDIAN__
- vec_cnttz((vector unsigned long long)__tmp2);
+ vec_cnttz((vector unsigned long long)__tmp2);
#else
- vec_cntlz((vector unsigned long long)__tmp2);
+ vec_cntlz((vector unsigned long long)__tmp2);
#endif
if (__res[0] == 64) {
return (__res[1] + 64) >> 3;
@@ -2317,14 +2343,15 @@ static __inline__ unsigned __ATTRS_o_ai
vec_first_match_or_eos_index(vector unsigned char __a,
vector unsigned char __b) {
vector bool char __tmp1 = vec_cmpeq(__a, __b);
- vector bool char __tmp2 = __tmp1 | vec_cmpeq(__tmp1, __a) |
- vec_cmpeq(__tmp1, __b);
+ vector bool char __tmp2 = __tmp1 |
+ vec_cmpeq((vector unsigned char)__tmp1, __a) |
+ vec_cmpeq((vector unsigned char)__tmp1, __b);
vector unsigned long long __res =
#ifdef __LITTLE_ENDIAN__
- vec_cnttz((vector unsigned long long)__tmp2);
+ vec_cnttz((vector unsigned long long)__tmp2);
#else
- vec_cntlz((vector unsigned long long)__tmp2);
+ vec_cntlz((vector unsigned long long)__tmp2);
#endif
if (__res[0] == 64) {
return (__res[1] + 64) >> 3;
@@ -2335,14 +2362,15 @@ vec_first_match_or_eos_index(vector unsi
static __inline__ unsigned __ATTRS_o_ai
vec_first_match_or_eos_index(vector signed short __a, vector signed short __b) {
vector bool short __tmp1 = vec_cmpeq(__a, __b);
- vector bool short __tmp2 = __tmp1 | vec_cmpeq(__tmp1, __a) |
- vec_cmpeq(__tmp1, __b);
+ vector bool short __tmp2 = __tmp1 |
+ vec_cmpeq((vector signed short)__tmp1, __a) |
+ vec_cmpeq((vector signed short)__tmp1, __b);
vector unsigned long long __res =
#ifdef __LITTLE_ENDIAN__
- vec_cnttz((vector unsigned long long)__tmp2);
+ vec_cnttz((vector unsigned long long)__tmp2);
#else
- vec_cntlz((vector unsigned long long)__tmp2);
+ vec_cntlz((vector unsigned long long)__tmp2);
#endif
if (__res[0] == 64) {
return (__res[1] + 64) >> 4;
@@ -2354,14 +2382,15 @@ static __inline__ unsigned __ATTRS_o_ai
vec_first_match_or_eos_index(vector unsigned short __a,
vector unsigned short __b) {
vector bool short __tmp1 = vec_cmpeq(__a, __b);
- vector bool short __tmp2 = __tmp1 | vec_cmpeq(__tmp1, __a) |
- vec_cmpeq(__tmp1, __b);
+ vector bool short __tmp2 = __tmp1 |
+ vec_cmpeq((vector unsigned short)__tmp1, __a) |
+ vec_cmpeq((vector unsigned short)__tmp1, __b);
vector unsigned long long __res =
#ifdef __LITTLE_ENDIAN__
- vec_cnttz((vector unsigned long long)__tmp2);
+ vec_cnttz((vector unsigned long long)__tmp2);
#else
- vec_cntlz((vector unsigned long long)__tmp2);
+ vec_cntlz((vector unsigned long long)__tmp2);
#endif
if (__res[0] == 64) {
return (__res[1] + 64) >> 4;
@@ -2372,14 +2401,14 @@ vec_first_match_or_eos_index(vector unsi
static __inline__ unsigned __ATTRS_o_ai
vec_first_match_or_eos_index(vector signed int __a, vector signed int __b) {
vector bool int __tmp1 = vec_cmpeq(__a, __b);
- vector bool int __tmp2 = __tmp1 | vec_cmpeq(__tmp1, __a) |
- vec_cmpeq(__tmp1, __b);
+ vector bool int __tmp2 = __tmp1 | vec_cmpeq((vector signed int)__tmp1, __a) |
+ vec_cmpeq((vector signed int)__tmp1, __b);
vector unsigned long long __res =
#ifdef __LITTLE_ENDIAN__
- vec_cnttz((vector unsigned long long)__tmp2);
+ vec_cnttz((vector unsigned long long)__tmp2);
#else
- vec_cntlz((vector unsigned long long)__tmp2);
+ vec_cntlz((vector unsigned long long)__tmp2);
#endif
if (__res[0] == 64) {
return (__res[1] + 64) >> 5;
@@ -2388,11 +2417,11 @@ vec_first_match_or_eos_index(vector sign
}
static __inline__ unsigned __ATTRS_o_ai
-vec_first_match_or_eos_index(vector unsigned int __a,
- vector unsigned int __b) {
+vec_first_match_or_eos_index(vector unsigned int __a, vector unsigned int __b) {
vector bool int __tmp1 = vec_cmpeq(__a, __b);
- vector bool int __tmp2 = __tmp1 | vec_cmpeq(__tmp1, __a) |
- vec_cmpeq(__tmp1, __b);
+ vector bool int __tmp2 = __tmp1 |
+ vec_cmpeq((vector unsigned int)__tmp1, __a) |
+ vec_cmpeq((vector unsigned int)__tmp1, __b);
vector unsigned long long __res =
#ifdef __LITTLE_ENDIAN__
Modified: cfe/trunk/test/CodeGen/builtins-ppc-altivec.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-altivec.c?rev=286205&r1=286204&r2=286205&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-ppc-altivec.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-altivec.c Mon Nov 7 22:15:45 2016
@@ -938,6 +938,14 @@ void test2() {
// CHECK: @llvm.ppc.altivec.vcmpequb
// CHECK-LE: @llvm.ppc.altivec.vcmpequb
+ res_vbc = vec_cmpeq(vbc, vbc);
+// CHECK: @llvm.ppc.altivec.vcmpequb
+// CHECK-LE: @llvm.ppc.altivec.vcmpequb
+
+ res_vbc = vec_cmpeq(vbc, vbc);
+// CHECK: @llvm.ppc.altivec.vcmpequb
+// CHECK-LE: @llvm.ppc.altivec.vcmpequb
+
res_vbs = vec_cmpeq(vs, vs);
// CHECK: @llvm.ppc.altivec.vcmpequh
// CHECK-LE: @llvm.ppc.altivec.vcmpequh
@@ -946,6 +954,14 @@ void test2() {
// CHECK: @llvm.ppc.altivec.vcmpequh
// CHECK-LE: @llvm.ppc.altivec.vcmpequh
+ res_vbs = vec_cmpeq(vbs, vbs);
+// CHECK: @llvm.ppc.altivec.vcmpequh
+// CHECK-LE: @llvm.ppc.altivec.vcmpequh
+
+ res_vbs = vec_cmpeq(vbs, vbs);
+// CHECK: @llvm.ppc.altivec.vcmpequh
+// CHECK-LE: @llvm.ppc.altivec.vcmpequh
+
res_vbi = vec_cmpeq(vi, vi);
// CHECK: @llvm.ppc.altivec.vcmpequw
// CHECK-LE: @llvm.ppc.altivec.vcmpequw
@@ -954,6 +970,14 @@ void test2() {
// CHECK: @llvm.ppc.altivec.vcmpequw
// CHECK-LE: @llvm.ppc.altivec.vcmpequw
+ res_vbi = vec_cmpeq(vbi, vbi);
+// CHECK: @llvm.ppc.altivec.vcmpequw
+// CHECK-LE: @llvm.ppc.altivec.vcmpequw
+
+ res_vbi = vec_cmpeq(vbi, vbi);
+// CHECK: @llvm.ppc.altivec.vcmpequw
+// CHECK-LE: @llvm.ppc.altivec.vcmpequw
+
res_vbi = vec_cmpeq(vf, vf);
// CHECK: @llvm.ppc.altivec.vcmpeqfp
// CHECK-LE: @llvm.ppc.altivec.vcmpeqfp
Modified: cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c?rev=286205&r1=286204&r2=286205&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-p8vector.c Mon Nov 7 22:15:45 2016
@@ -151,6 +151,11 @@ void test1() {
// CHECK-PPC: warning: implicit declaration of function 'vec_mergeo'
/* vec_cmpeq */
+ res_vbll = vec_cmpeq(vbll, vbll);
+// CHECK: @llvm.ppc.altivec.vcmpequd
+// CHECK-LE: @llvm.ppc.altivec.vcmpequd
+// CHECK-PPC: error: call to 'vec_cmpeq' is ambiguous
+
res_vbll = vec_cmpeq(vsll, vsll);
// CHECK: @llvm.ppc.altivec.vcmpequd
// CHECK-LE: @llvm.ppc.altivec.vcmpequd
More information about the cfe-commits
mailing list