jtony updated this revision to Diff 76862.
jtony marked 2 inline comments as done.
jtony added a comment.

Fix a few format and layout issues.

Format: clang-format is not always correct, sometimes separate parameters in 
different lines is better.
Layout: put the overloaded builtin functions  in such order:  signed version, 
unsigned version and bool version.


https://reviews.llvm.org/D26160

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-altivec.c
  test/CodeGen/builtins-ppc-p8vector.c

Index: test/CodeGen/builtins-ppc-p8vector.c
===================================================================
--- test/CodeGen/builtins-ppc-p8vector.c
+++ test/CodeGen/builtins-ppc-p8vector.c
@@ -151,6 +151,11 @@
 // 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
Index: test/CodeGen/builtins-ppc-altivec.c
===================================================================
--- test/CodeGen/builtins-ppc-altivec.c
+++ test/CodeGen/builtins-ppc-altivec.c
@@ -938,22 +938,34 @@
 // 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
 
   res_vbs = vec_cmpeq(vus, vus);
 // 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
 
   res_vbi = vec_cmpeq(vui, vui);
 // 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
Index: lib/Headers/altivec.h
===================================================================
--- lib/Headers/altivec.h
+++ lib/Headers/altivec.h
@@ -1564,6 +1564,12 @@
                                                       (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 @@
                                                        (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 @@
                                                      (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 @@
   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 @@
      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 @@
 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 @@
 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 @@
 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,27 +2401,27 @@
 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;
   }
   return __res[0] >> 5;
 }
 
 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__
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to