Author: Nemanja Ivanovic Date: 2021-03-23T05:52:36-05:00 New Revision: 2f782a796a2b0a4bb5ff772577f96eacdb9254c1
URL: https://github.com/llvm/llvm-project/commit/2f782a796a2b0a4bb5ff772577f96eacdb9254c1 DIFF: https://github.com/llvm/llvm-project/commit/2f782a796a2b0a4bb5ff772577f96eacdb9254c1.diff LOG: [PowerPC] Add more missing overloads to altivec.h Add overloads that perform subtraction on v1i128 that take and produce vector unsigned char to avoid needing to use __int128. The overloads are suffixed with _u128 and are needed for targets where __int128 isn't supported (AIX). Added: Modified: clang/lib/Headers/altivec.h clang/test/CodeGen/builtins-ppc-quadword.c Removed: ################################################################################ diff --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h index f3340f20b7b4..c5674413e483 100644 --- a/clang/lib/Headers/altivec.h +++ b/clang/lib/Headers/altivec.h @@ -11636,6 +11636,12 @@ static __inline__ vector signed __int128 __ATTRS_o_ai vec_subc(vector signed __int128 __a, vector signed __int128 __b) { return __builtin_altivec_vsubcuq(__a, __b); } + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_subc_u128(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vsubcuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b); +} #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__) /* vec_vsubcuw */ @@ -11852,6 +11858,12 @@ vec_vsubuqm(vector unsigned __int128 __a, vector unsigned __int128 __b) { return __a - __b; } +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_sub_u128(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)((vector unsigned __int128)__a - + (vector unsigned __int128)__b); +} + /* vec_vsubeuqm */ @@ -11879,6 +11891,14 @@ vec_sube(vector unsigned __int128 __a, vector unsigned __int128 __b, return __builtin_altivec_vsubeuqm(__a, __b, __c); } +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_sube_u128(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return (vector unsigned char)__builtin_altivec_vsubeuqm( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} + /* vec_vsubcuq */ static __inline__ vector signed __int128 __ATTRS_o_ai @@ -11928,6 +11948,14 @@ vec_subec(vector unsigned __int128 __a, vector unsigned __int128 __b, vector unsigned __int128 __c) { return __builtin_altivec_vsubecuq(__a, __b, __c); } + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_subec_u128(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return (vector unsigned char)__builtin_altivec_vsubecuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__) static __inline__ vector signed int __ATTRS_o_ai diff --git a/clang/test/CodeGen/builtins-ppc-quadword.c b/clang/test/CodeGen/builtins-ppc-quadword.c index 66cc9e8c7a88..561f0c28f225 100644 --- a/clang/test/CodeGen/builtins-ppc-quadword.c +++ b/clang/test/CodeGen/builtins-ppc-quadword.c @@ -14,6 +14,7 @@ vector signed __int128 vlll = { -1 }; // CHECK-PPC: error: __int128 is not supported on this target vector unsigned __int128 vulll = { 1 }; +vector unsigned char vuc; signed long long param_sll; // CHECK-PPC: error: __int128 is not supported on this target @@ -25,6 +26,7 @@ unsigned __int128 param_ulll; vector signed __int128 res_vlll; // CHECK-PPC: error: __int128 is not supported on this target vector unsigned __int128 res_vulll; +vector unsigned char res_vuc; // CHECK-LABEL: define{{.*}} void @test1 @@ -119,6 +121,10 @@ void test1() { // CHECK-LE: sub <1 x i128> // CHECK-PPC: error: assigning to '__vector unsigned __int128' (vector of 1 'unsigned __int128' value) from incompatible type 'int' + res_vuc = vec_sub_u128(vuc, vuc); +// CHECK: sub <1 x i128> +// CHECK-LE: sub <1 x i128> + /* vec_vsubeuqm */ res_vlll = vec_vsubeuqm(vlll, vlll, vlll); // CHECK: @llvm.ppc.altivec.vsubeuqm @@ -151,6 +157,10 @@ void test1() { // CHECK-LE: @llvm.ppc.altivec.vsubeuqm // CHECK-PPC: error: call to 'vec_sube' is ambiguous + res_vuc = vec_sube_u128(vuc, vuc, vuc); +// CHECK: @llvm.ppc.altivec.vsubeuqm +// CHECK-LE: @llvm.ppc.altivec.vsubeuqm + /* vec_subc */ res_vlll = vec_subc(vlll, vlll); // CHECK: @llvm.ppc.altivec.vsubcuq @@ -162,6 +172,10 @@ void test1() { // CHECK-LE: @llvm.ppc.altivec.vsubcuq // KCHECK-PPC: error: call to 'vec_subc' is ambiguous + res_vuc = vec_subc_u128(vuc, vuc); +// CHECK: @llvm.ppc.altivec.vsubcuq +// CHECK-LE: @llvm.ppc.altivec.vsubcuq + /* vec_vsubcuq */ res_vlll = vec_vsubcuq(vlll, vlll); // CHECK: @llvm.ppc.altivec.vsubcuq @@ -194,6 +208,10 @@ void test1() { // CHECK-LE: @llvm.ppc.altivec.vsubecuq // CHECK-PPC: error: assigning to '__vector unsigned __int128' (vector of 1 'unsigned __int128' value) from incompatible type 'int' + res_vuc = vec_subec_u128(vuc, vuc, vuc); +// CHECK: @llvm.ppc.altivec.vsubecuq +// CHECK-LE: @llvm.ppc.altivec.vsubecuq + res_vulll = vec_revb(vulll); // CHECK: store <16 x i8> <i8 15, i8 14, i8 13, i8 12, i8 11, i8 10, i8 9, i8 8, i8 7, i8 6, i8 5, i8 4, i8 3, i8 2, i8 1, i8 0>, <16 x i8>* {{%.+}}, align 16 // CHECK: call <4 x i32> @llvm.ppc.altivec.vperm(<4 x i32> {{%.+}}, <4 x i32> {{%.+}}, <16 x i8> {{%.+}}) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits