From 282c18287198c4f89f2d68fde5f5f972158e7ccf Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 17 Sep 2019 03:56:26 +0000 Subject: [PATCH] Remove reliance on lax vector conversions from altivec.h in VSX mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@372061 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Headers/altivec.h | 41 +++++++++++++++------------- test/CodeGen/altivec-ct.c | 4 +-- test/CodeGen/builtins-ppc-error.c | 9 ++++++ test/CodeGen/builtins-ppc-p9vector.c | 10 ++++++- test/CodeGen/builtins-ppc-vsx.c | 2 +- 5 files changed, 43 insertions(+), 23 deletions(-) diff --git a/lib/Headers/altivec.h b/lib/Headers/altivec.h index bc26f1089d..8352f8f740 100644 --- a/lib/Headers/altivec.h +++ b/lib/Headers/altivec.h @@ -2761,8 +2761,8 @@ static __inline__ vector double __ATTRS_o_ai vec_xl_len(double *__a, return (vector double)__builtin_vsx_lxvl(__a, (__b << 56)); } -static __inline__ vector double __ATTRS_o_ai vec_xl_len_r(unsigned char *__a, - size_t __b) { +static __inline__ vector unsigned char __ATTRS_o_ai +vec_xl_len_r(unsigned char *__a, size_t __b) { vector unsigned char __res = (vector unsigned char)__builtin_vsx_lxvll(__a, (__b << 56)); #ifdef __LITTLE_ENDIAN__ @@ -2912,10 +2912,11 @@ static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a, #ifdef __VSX__ #define vec_cts(__a, __b) \ _Generic((__a), vector float \ - : __builtin_altivec_vctsxs((__a), (__b)), vector double \ + : __builtin_altivec_vctsxs((vector float)(__a), (__b)), \ + vector double \ : __extension__({ \ vector double __ret = \ - (__a) * \ + (vector double)(__a) * \ (vector double)(vector unsigned long long)((0x3ffULL + (__b)) \ << 52); \ __builtin_convertvector(__ret, vector signed long long); \ @@ -2933,10 +2934,11 @@ static __inline__ vector double __ATTRS_o_ai vec_cpsgn(vector double __a, #ifdef __VSX__ #define vec_ctu(__a, __b) \ _Generic((__a), vector float \ - : __builtin_altivec_vctuxs((__a), (__b)), vector double \ + : __builtin_altivec_vctuxs((vector float)(__a), (__b)), \ + vector double \ : __extension__({ \ vector double __ret = \ - (__a) * \ + (vector double)(__a) * \ (vector double)(vector unsigned long long)((0x3ffULL + __b) \ << 52); \ __builtin_convertvector(__ret, vector unsigned long long); \ @@ -6301,19 +6303,20 @@ static __inline__ vector float __ATTRS_o_ai vec_or(vector float __a, #ifdef __VSX__ static __inline__ vector double __ATTRS_o_ai vec_or(vector bool long long __a, vector double __b) { - return (vector unsigned long long)__a | (vector unsigned long long)__b; + return (vector double)((vector unsigned long long)__a | + (vector unsigned long long)__b); } static __inline__ vector double __ATTRS_o_ai vec_or(vector double __a, vector bool long long __b) { - return (vector unsigned long long)__a | (vector unsigned long long)__b; + return (vector double)((vector unsigned long long)__a | + (vector unsigned long long)__b); } static __inline__ vector double __ATTRS_o_ai vec_or(vector double __a, vector double __b) { - vector unsigned long long __res = - (vector unsigned long long)__a | (vector unsigned long long)__b; - return (vector double)__res; + return (vector double)((vector unsigned long long)__a | + (vector unsigned long long)__b); } static __inline__ vector signed long long __ATTRS_o_ai @@ -14781,7 +14784,7 @@ static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool long long __a, static __inline__ int __ATTRS_o_ai vec_all_ne(vector float __a, vector float __b) { #ifdef __VSX__ - return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, __a, __b); + return __builtin_vsx_xvcmpeqdp_p(__CR6_EQ, (vector double)__a, (vector double)__b); #else return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, __a, __b); #endif @@ -16671,13 +16674,13 @@ static __inline__ void __ATTRS_o_ai vec_xst_be(vector unsigned __int128 __vec, #endif #ifdef __POWER9_VECTOR__ -#define vec_test_data_class(__a, __b) \ - _Generic((__a), \ - vector float: \ - (vector bool int)__builtin_vsx_xvtstdcsp((__a), (__b)), \ - vector double: \ - (vector bool long long)__builtin_vsx_xvtstdcdp((__a), (__b)) \ - ) +#define vec_test_data_class(__a, __b) \ + _Generic( \ + (__a), vector float \ + : (vector bool int)__builtin_vsx_xvtstdcsp((vector float)(__a), (__b)), \ + vector double \ + : (vector bool long long)__builtin_vsx_xvtstdcdp((vector double)(__a), \ + (__b))) #endif /* #ifdef __POWER9_VECTOR__ */ diff --git a/test/CodeGen/altivec-ct.c b/test/CodeGen/altivec-ct.c index 1a3e14dc1f..e36f556eb9 100644 --- a/test/CodeGen/altivec-ct.c +++ b/test/CodeGen/altivec-ct.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple powerpc64le-linux-gnu -S -O0 -o - %s -target-feature +altivec -target-feature +vsx | FileCheck %s -check-prefix=CHECK -check-prefix=VSX -// RUN: %clang_cc1 -triple powerpc-linux-gnu -S -O0 -o - %s -target-feature +altivec -target-feature -vsx | FileCheck %s +// RUN: %clang_cc1 -flax-vector-conversions=none -triple powerpc64le-linux-gnu -S -O0 -o - %s -target-feature +altivec -target-feature +vsx | FileCheck %s -check-prefix=CHECK -check-prefix=VSX +// RUN: %clang_cc1 -flax-vector-conversions=none -triple powerpc-linux-gnu -S -O0 -o - %s -target-feature +altivec -target-feature -vsx | FileCheck %s // REQUIRES: powerpc-registered-target diff --git a/test/CodeGen/builtins-ppc-error.c b/test/CodeGen/builtins-ppc-error.c index 39a2458226..80ca227eeb 100644 --- a/test/CodeGen/builtins-ppc-error.c +++ b/test/CodeGen/builtins-ppc-error.c @@ -2,10 +2,19 @@ // RUN: %clang_cc1 -target-feature +altivec -target-feature +power9-vector \ // RUN: -triple powerpc64-unknown-unknown -fsyntax-only \ +// RUN: -flax-vector-conversions=integer \ // RUN: -Wall -Werror -verify %s // RUN: %clang_cc1 -target-feature +altivec -target-feature +power9-vector \ // RUN: -triple powerpc64le-unknown-unknown -fsyntax-only \ +// RUN: -flax-vector-conversions=integer \ +// RUN: -Wall -Werror -verify %s + +// FIXME: Fix so this test also passes under +// -flax-vector-conversions=none (this last test exists to produce an error if +// we change the default to that without fixing ). +// RUN: %clang_cc1 -target-feature +altivec -target-feature +power9-vector \ +// RUN: -triple powerpc64-unknown-unknown -fsyntax-only \ // RUN: -Wall -Werror -verify %s #include diff --git a/test/CodeGen/builtins-ppc-p9vector.c b/test/CodeGen/builtins-ppc-p9vector.c index bfbb815854..e920cb76f4 100644 --- a/test/CodeGen/builtins-ppc-p9vector.c +++ b/test/CodeGen/builtins-ppc-p9vector.c @@ -1,12 +1,20 @@ // REQUIRES: powerpc-registered-target // RUN: %clang_cc1 -target-feature +altivec -target-feature +power9-vector \ // RUN: -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN: -flax-vector-conversions=integer \ // RUN: -o - | FileCheck %s -check-prefix=CHECK-BE // RUN: %clang_cc1 -target-feature +altivec -target-feature +power9-vector \ // RUN: -triple powerpc64le-unknown-unknown -emit-llvm %s \ +// RUN: -flax-vector-conversions=integer \ // RUN: -o - | FileCheck %s +// FIXME: This last test is intended to fail if the default is changed to +// -flax-vector-conversions=none and isn't fixed first. +// RUN: %clang_cc1 -target-feature +altivec -target-feature +power9-vector \ +// RUN: -triple powerpc64-unknown-unknown -emit-llvm %s \ +// RUN: -o - | FileCheck %s -check-prefix=CHECK-BE + #include vector signed char vsca, vscb; @@ -919,7 +927,7 @@ vector double test80(void) { // CHECK: insertelement <2 x double> return vec_unpackl(vfa); } -vector double test81(void) { +vector float test81(void) { // CHECK: extractelement <2 x double> // CHECK: fptrunc double // CHECK: insertelement <4 x float> diff --git a/test/CodeGen/builtins-ppc-vsx.c b/test/CodeGen/builtins-ppc-vsx.c index 838d94cf7d..0c797a389b 100644 --- a/test/CodeGen/builtins-ppc-vsx.c +++ b/test/CodeGen/builtins-ppc-vsx.c @@ -882,7 +882,7 @@ void test1() { // CHECK: call void @dummy() // CHECK-LE: call void @dummy() - res_vf = vec_sel(vd, vd, vbll); + res_vd = vec_sel(vd, vd, vbll); // CHECK: xor <2 x i64> %{{[0-9]+}}, // CHECK: and <2 x i64> %{{[0-9]+}}, // CHECK: and <2 x i64> %{{[0-9]+}}, %{{[0-9]+}} -- 2.40.0