r257135 - [PPC] Add long long/double support for vec_cts, vec_ctu and vec_ctf

Kyle Butt via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 7 18:00:48 PST 2016


Author: iteratee
Date: Thu Jan  7 20:00:48 2016
New Revision: 257135

URL: http://llvm.org/viewvc/llvm-project?rev=257135&view=rev
Log:
[PPC] Add long long/double support for vec_cts, vec_ctu and vec_ctf

Add long long/double support for vec_cts, vec_ctu and vec_ctf.

Similar to this change in GCC:
https://gcc.gnu.org/ml/gcc-patches/2014-08/msg02653.html

Patch by Tim Shen.

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

Modified: cfe/trunk/lib/Headers/altivec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=257135&r1=257134&r2=257135&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Thu Jan  7 20:00:48 2016
@@ -1891,6 +1891,22 @@ static vector float __ATTRS_o_ai vec_ctf
   return __builtin_altivec_vcfux((vector int)__a, __b);
 }
 
+#ifdef __VSX__
+static vector double __ATTRS_o_ai vec_ctf(vector unsigned long long __a,
+                                          int __b) {
+  vector double __ret = __builtin_convertvector(__a, vector double);
+  __ret *= (vector double)(vector unsigned long long)((0x3ffULL - __b) << 52);
+  return __ret;
+}
+
+static vector double __ATTRS_o_ai vec_ctf(vector signed long long __a,
+                                          int __b) {
+  vector double __ret = __builtin_convertvector(__a, vector double);
+  __ret *= (vector double)(vector unsigned long long)((0x3ffULL - __b) << 52);
+  return __ret;
+}
+#endif
+
 /* vec_vcfsx */
 
 static vector float __attribute__((__always_inline__))
@@ -1907,11 +1923,18 @@ vec_vcfux(vector unsigned int __a, int _
 
 /* vec_cts */
 
-static vector int __attribute__((__always_inline__))
-vec_cts(vector float __a, int __b) {
+static vector int __ATTRS_o_ai vec_cts(vector float __a, int __b) {
   return __builtin_altivec_vctsxs(__a, __b);
 }
 
+#ifdef __VSX__
+static vector signed long long __ATTRS_o_ai vec_cts(vector double __a,
+                                                    int __b) {
+  __a *= (vector double)(vector unsigned long long)((0x3ffULL + __b) << 52);
+  return __builtin_convertvector(__a, vector signed long long);
+}
+#endif
+
 /* vec_vctsxs */
 
 static vector int __attribute__((__always_inline__))
@@ -1921,11 +1944,18 @@ vec_vctsxs(vector float __a, int __b) {
 
 /* vec_ctu */
 
-static vector unsigned int __attribute__((__always_inline__))
-vec_ctu(vector float __a, int __b) {
+static vector unsigned int __ATTRS_o_ai vec_ctu(vector float __a, int __b) {
   return __builtin_altivec_vctuxs(__a, __b);
 }
 
+#ifdef __VSX__
+static vector unsigned long long __ATTRS_o_ai vec_ctu(vector double __a,
+                                                      int __b) {
+  __a *= (vector double)(vector unsigned long long)((0x3ffULL + __b) << 52);
+  return __builtin_convertvector(__a, vector unsigned long long);
+}
+#endif
+
 /* vec_vctuxs */
 
 static vector unsigned int __attribute__((__always_inline__))

Modified: cfe/trunk/test/CodeGen/builtins-ppc-vsx.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-vsx.c?rev=257135&r1=257134&r2=257135&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-ppc-vsx.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-vsx.c Thu Jan  7 20:00:48 2016
@@ -845,4 +845,51 @@ void test1() {
 // CHECK: xor <2 x i64>
 // CHECK-LE: xor <2 x i64>
 
+  res_vsll = vec_cts(vd, 0);
+// CHECK: fmul <2 x double>
+// CHECK: fptosi <2 x double> %{{.*}} to <2 x i64>
+// CHECK-LE: fmul <2 x double>
+// CHECK-LE: fptosi <2 x double> %{{.*}} to <2 x i64>
+
+  res_vsll = vec_cts(vd, 31);
+// CHECK: fmul <2 x double>
+// CHECK: fptosi <2 x double> %{{.*}} to <2 x i64>
+// CHECK-LE: fmul <2 x double>
+// CHECK-LE: fptosi <2 x double> %{{.*}} to <2 x i64>
+
+  res_vsll = vec_ctu(vd, 0);
+// CHECK: fmul <2 x double>
+// CHECK: fptoui <2 x double> %{{.*}} to <2 x i64>
+// CHECK-LE: fmul <2 x double>
+// CHECK-LE: fptoui <2 x double> %{{.*}} to <2 x i64>
+
+  res_vsll = vec_ctu(vd, 31);
+// CHECK: fmul <2 x double>
+// CHECK: fptoui <2 x double> %{{.*}} to <2 x i64>
+// CHECK-LE: fmul <2 x double>
+// CHECK-LE: fptoui <2 x double> %{{.*}} to <2 x i64>
+
+  res_vd = vec_ctf(vsll, 0);
+// CHECK: sitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK: fmul <2 x double>
+// CHECK-LE: sitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK-LE: fmul <2 x double>
+
+  res_vd = vec_ctf(vsll, 31);
+// CHECK: sitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK: fmul <2 x double>
+// CHECK-LE: sitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK-LE: fmul <2 x double>
+
+  res_vd = vec_ctf(vull, 0);
+// CHECK: uitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK: fmul <2 x double>
+// CHECK-LE: uitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK-LE: fmul <2 x double>
+
+  res_vd = vec_ctf(vull, 31);
+// CHECK: uitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK: fmul <2 x double>
+// CHECK-LE: uitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK-LE: fmul <2 x double>
 }




More information about the cfe-commits mailing list