[clang] a1d325a - [PowerPC] Add vec_roundz as alias for vec_trunc in altivec.h

Nemanja Ivanovic via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 22 08:31:29 PDT 2021


Author: Nemanja Ivanovic
Date: 2021-04-22T10:31:00-05:00
New Revision: a1d325af6708ebd8ac9efb8d2d148f16feeda3fd

URL: https://github.com/llvm/llvm-project/commit/a1d325af6708ebd8ac9efb8d2d148f16feeda3fd
DIFF: https://github.com/llvm/llvm-project/commit/a1d325af6708ebd8ac9efb8d2d148f16feeda3fd.diff

LOG: [PowerPC] Add vec_roundz as alias for vec_trunc in altivec.h

Add the overloads for compatibility with XLC.

Added: 
    

Modified: 
    clang/lib/Headers/altivec.h
    clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index a47d5f90dbe2..1ffc46988721 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -12145,6 +12145,17 @@ static __inline__ vector double __ATTRS_o_ai vec_trunc(vector double __a) {
 }
 #endif
 
+/* vec_roundz */
+static __inline__ vector float __ATTRS_o_ai vec_roundz(vector float __a) {
+  return vec_trunc(__a);
+}
+
+#ifdef __VSX__
+static __inline__ vector double __ATTRS_o_ai vec_roundz(vector double __a) {
+  return vec_trunc(__a);
+}
+#endif
+
 /* vec_vrfiz */
 
 static __inline__ vector float __attribute__((__always_inline__))

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c b/clang/test/CodeGen/builtins-ppc-vsx.c
index 87cd776e2694..ad27b823bcda 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -1151,6 +1151,14 @@ void test1() {
 
   res_vd = vec_trunc(vd);
 // CHECK: call <2 x double> @llvm.trunc.v2f64(<2 x double> %{{[0-9]+}})
+// CHECK-LE: call <2 x double> @llvm.trunc.v2f64(<2 x double> %{{[0-9]+}})
+
+  res_vf = vec_roundz(vf);
+// CHECK: call <4 x float> @llvm.trunc.v4f32(<4 x float> %{{[0-9]+}})
+// CHECK-LE: call <4 x float> @llvm.trunc.v4f32(<4 x float> %{{[0-9]+}})
+
+  res_vd = vec_roundz(vd);
+// CHECK: call <2 x double> @llvm.trunc.v2f64(<2 x double> %{{[0-9]+}})
 // CHECK-LE: call <2 x double> @llvm.trunc.v2f64(<2 x double> %{{[0-9]+}})
 
   /* vec_vor */


        


More information about the cfe-commits mailing list