[PATCH] D27251: [PPC] some bugs mainly about sign problem fixed in altivec.h

Kit Barton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 1 09:14:04 PST 2016


kbarton requested changes to this revision.
kbarton added a comment.
This revision now requires changes to proceed.

Please make explicit the signed for the parameters to the functions you are changing and remove unnecessary casts. I marked the first few that I found, but stopped marking them after the first several.



================
Comment at: lib/Headers/altivec.h:13928
                                               vector signed char __b) {
-  return __builtin_altivec_vcmpgtub_p(__CR6_EQ, (vector unsigned char)__b,
-                                      (vector unsigned char)__a);
+  return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, (vector signed char)__b,
+                                      (vector signed char)__a);
----------------
The cast for  __b is necessary, since it is already a vector signed char. 
I don't know whether this will generate superfluous warnings or not, but it's probably best to remove it.


================
Comment at: lib/Headers/altivec.h:13965
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool short __a,
                                               vector short __b) {
+  return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, (vector signed short)__b,
----------------
It's better to make the parameter explicitly vector signed short, and remove the cast on the next line, for consistency with other builtins. 


================
Comment at: lib/Headers/altivec.h:14002
 static __inline__ int __ATTRS_o_ai vec_all_ge(vector bool int __a,
                                               vector int __b) {
+  return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, (vector signed int)__b,
----------------
same comment - explicitly vector signed int


================
Comment at: lib/Headers/altivec.h:14042
                                               vector signed long long __b) {
-  return __builtin_altivec_vcmpgtud_p(__CR6_EQ, (vector unsigned long long)__b,
-                                      (vector unsigned long long)__a);
+  return __builtin_altivec_vcmpgtsd_p(__CR6_EQ, (vector signed long long)__b,
+                                      (vector signed long long)__a);
----------------
No cast needed here


================
Comment at: lib/Headers/altivec.h:14099
                                               vector signed char __b) {
-  return __builtin_altivec_vcmpgtub_p(__CR6_LT, (vector unsigned char)__a,
-                                      (vector unsigned char)__b);
+  return __builtin_altivec_vcmpgtsb_p(__CR6_LT, (vector signed char)__a,
+                                      (vector signed char)__b);
----------------
No cast needed here 


================
Comment at: lib/Headers/altivec.h:14136
 static __inline__ int __ATTRS_o_ai vec_all_gt(vector bool short __a,
                                               vector short __b) {
+  return __builtin_altivec_vcmpgtsh_p(__CR6_LT, (vector signed short)__a,
----------------
Make signed explicit here


https://reviews.llvm.org/D27251





More information about the cfe-commits mailing list