[clang] a0e6189 - [PowerPC] Add vec_xlds to altivec.h

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


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

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

LOG: [PowerPC] Add vec_xlds to altivec.h

Add these overloads for compatibility with XLC. This is a doubleword
load-and-splat.

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 1ffc46988721..e48650602c78 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -17405,6 +17405,24 @@ vec_xl_zext(ptr
diff _t __offset, const unsigned long long *__pointer) {
 
 #endif
 
+/* vec_xlds */
+#ifdef __VSX__
+static __inline__ vector signed long long __ATTRS_o_ai vec_xlds(ptr
diff _t __offset, const signed long long *__ptr) {
+  signed long long *__addr = (signed char *)__ptr + __offset;
+  return (vector signed long long) *__addr;
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai vec_xlds(ptr
diff _t __offset, const unsigned long long *__ptr) {
+  unsigned long long *__addr = (signed char *)__ptr + __offset;
+  return (unaligned_vec_ull) *__addr;
+}
+
+static __inline__ vector double __ATTRS_o_ai vec_xlds(ptr
diff _t __offset, const double *__ptr) {
+  double *__addr = (signed char *)__ptr + __offset;
+  return (unaligned_vec_double) *__addr;
+}
+#endif
+
 /* vec_xst */
 
 #define vec_xstd2 vec_xst

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c b/clang/test/CodeGen/builtins-ppc-vsx.c
index ad27b823bcda..f77cd5a1528d 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -1948,6 +1948,30 @@ res_vd = vec_xl_be(sll, ad);
 // CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 1
 // CHECK-LE: call <2 x double> @llvm.ppc.vsx.lxvd2x.be(i8* %{{[0-9]+}})
 
+res_vsll = vec_xlds(sll, asll);
+// CHECK: load i64
+// CHECK: insertelement <2 x i64>
+// CHECK: shufflevector <2 x i64>
+// CHECK-LE: load i64
+// CHECK-LE: insertelement <2 x i64>
+// CHECK-LE: shufflevector <2 x i64>
+
+res_vull = vec_xlds(sll, aull);
+// CHECK: load i64
+// CHECK: insertelement <2 x i64>
+// CHECK: shufflevector <2 x i64>
+// CHECK-LE: load i64
+// CHECK-LE: insertelement <2 x i64>
+// CHECK-LE: shufflevector <2 x i64>
+
+res_vd = vec_xlds(sll, ad);
+// CHECK: load double
+// CHECK: insertelement <2 x double>
+// CHECK: shufflevector <2 x double>
+// CHECK-LE: load double
+// CHECK-LE: insertelement <2 x double>
+// CHECK-LE: shufflevector <2 x double>
+
 vec_xst_be(vsll, sll, asll);
 // CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 1
 // CHECK-LE: call void @llvm.ppc.vsx.stxvd2x.be(<2 x double> %{{[0-9]+}}, i8* %{{[0-9]+}})


        


More information about the cfe-commits mailing list