[clang] e43963d - [PowerPC] Add vec_load_splats to altivec.h

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


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

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

LOG: [PowerPC] Add vec_load_splats to altivec.h

Add these overloads for compatibility with XLC. This is a word
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 e48650602c78..48b43cb78374 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -17407,20 +17407,60 @@ vec_xl_zext(ptr
diff _t __offset, const unsigned long long *__pointer) {
 
 /* vec_xlds */
 #ifdef __VSX__
-static __inline__ vector signed long long __ATTRS_o_ai vec_xlds(ptr
diff _t __offset, const signed long long *__ptr) {
+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) {
+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) {
+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;
 }
+
+/* vec_load_splats */
+static __inline__ vector signed int __ATTRS_o_ai
+vec_load_splats(signed long long __offset, const signed int *__ptr) {
+  signed int *__addr = (signed char *)__ptr + __offset;
+  return (vector signed int)*__addr;
+}
+
+static __inline__ vector signed int __ATTRS_o_ai
+vec_load_splats(unsigned long long __offset, const signed int *__ptr) {
+  signed int *__addr = (signed char *)__ptr + __offset;
+  return (vector signed int)*__addr;
+}
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_load_splats(signed long long __offset, const unsigned int *__ptr) {
+  unsigned int *__addr = (signed char *)__ptr + __offset;
+  return (vector unsigned int)*__addr;
+}
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_load_splats(unsigned long long __offset, const unsigned int *__ptr) {
+  unsigned int *__addr = (signed char *)__ptr + __offset;
+  return (vector unsigned int)*__addr;
+}
+
+static __inline__ vector float __ATTRS_o_ai
+vec_load_splats(signed long long __offset, const float *__ptr) {
+  float *__addr = (signed char *)__ptr + __offset;
+  return (vector float)*__addr;
+}
+
+static __inline__ vector float __ATTRS_o_ai
+vec_load_splats(unsigned long long __offset, const float *__ptr) {
+  float *__addr = (signed char *)__ptr + __offset;
+  return (vector float)*__addr;
+}
 #endif
 
 /* vec_xst */

diff  --git a/clang/test/CodeGen/builtins-ppc-vsx.c b/clang/test/CodeGen/builtins-ppc-vsx.c
index f77cd5a1528d..a8eaf341e8fc 100644
--- a/clang/test/CodeGen/builtins-ppc-vsx.c
+++ b/clang/test/CodeGen/builtins-ppc-vsx.c
@@ -1972,6 +1972,54 @@ res_vd = vec_xlds(sll, ad);
 // CHECK-LE: insertelement <2 x double>
 // CHECK-LE: shufflevector <2 x double>
 
+res_vsll = vec_load_splats(sll, asi);
+// CHECK: load i32
+// CHECK: insertelement <4 x i32>
+// CHECK: shufflevector <4 x i32>
+// CHECK-LE: load i32
+// CHECK-LE: insertelement <4 x i32>
+// CHECK-LE: shufflevector <4 x i32>
+
+res_vsll = vec_load_splats(ull, asi);
+// CHECK: load i32
+// CHECK: insertelement <4 x i32>
+// CHECK: shufflevector <4 x i32>
+// CHECK-LE: load i32
+// CHECK-LE: insertelement <4 x i32>
+// CHECK-LE: shufflevector <4 x i32>
+
+res_vsll = vec_load_splats(sll, aui);
+// CHECK: load i32
+// CHECK: insertelement <4 x i32>
+// CHECK: shufflevector <4 x i32>
+// CHECK-LE: load i32
+// CHECK-LE: insertelement <4 x i32>
+// CHECK-LE: shufflevector <4 x i32>
+
+res_vsll = vec_load_splats(ull, aui);
+// CHECK: load i32
+// CHECK: insertelement <4 x i32>
+// CHECK: shufflevector <4 x i32>
+// CHECK-LE: load i32
+// CHECK-LE: insertelement <4 x i32>
+// CHECK-LE: shufflevector <4 x i32>
+
+res_vsll = vec_load_splats(sll, af);
+// CHECK: load float
+// CHECK: insertelement <4 x float>
+// CHECK: shufflevector <4 x float>
+// CHECK-LE: load float
+// CHECK-LE: insertelement <4 x float>
+// CHECK-LE: shufflevector <4 x float>
+
+res_vsll = vec_load_splats(ull, af);
+// CHECK: load float
+// CHECK: insertelement <4 x float>
+// CHECK: shufflevector <4 x float>
+// CHECK-LE: load float
+// CHECK-LE: insertelement <4 x float>
+// CHECK-LE: shufflevector <4 x float>
+
 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