Author: Nemanja Ivanovic Date: 2021-03-23T05:09:19-05:00 New Revision: 54e4654f0465a960c1a6aeb02bb4ca33a3f19e67
URL: https://github.com/llvm/llvm-project/commit/54e4654f0465a960c1a6aeb02bb4ca33a3f19e67 DIFF: https://github.com/llvm/llvm-project/commit/54e4654f0465a960c1a6aeb02bb4ca33a3f19e67.diff LOG: [PowerPC] Add more missing overloads to altivec.h Add overloads that perform addition 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-p8vector.c Removed: ################################################################################ diff --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h index cabb7b225b84..f3340f20b7b4 100644 --- a/clang/lib/Headers/altivec.h +++ b/clang/lib/Headers/altivec.h @@ -304,6 +304,12 @@ static __inline__ vector unsigned __int128 __ATTRS_o_ai vec_add(vector unsigned __int128 __a, vector unsigned __int128 __b) { return __a + __b; } + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_add_u128(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)((vector unsigned __int128)__a + + (vector unsigned __int128)__b); +} #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__) static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a, @@ -332,6 +338,14 @@ vec_adde(vector unsigned __int128 __a, vector unsigned __int128 __b, vector unsigned __int128 __c) { return __builtin_altivec_vaddeuqm(__a, __b, __c); } + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_adde_u128(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return (vector unsigned char)__builtin_altivec_vaddeuqm( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} #endif static __inline__ vector signed int __ATTRS_o_ai @@ -365,6 +379,14 @@ vec_addec(vector unsigned __int128 __a, vector unsigned __int128 __b, return __builtin_altivec_vaddecuq(__a, __b, __c); } +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_addec_u128(vector unsigned char __a, vector unsigned char __b, + vector unsigned char __c) { + return (vector unsigned char)__builtin_altivec_vaddecuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b, + (vector unsigned __int128)__c); +} + static __inline__ vector signed int __ATTRS_o_ai vec_addec(vector signed int __a, vector signed int __b, vector signed int __c) { @@ -545,6 +567,12 @@ static __inline__ vector unsigned __int128 __ATTRS_o_ai vec_addc(vector unsigned __int128 __a, vector unsigned __int128 __b) { return __builtin_altivec_vaddcuq(__a, __b); } + +static __inline__ vector unsigned char __attribute__((__always_inline__)) +vec_addc_u128(vector unsigned char __a, vector unsigned char __b) { + return (vector unsigned char)__builtin_altivec_vaddcuq( + (vector unsigned __int128)__a, (vector unsigned __int128)__b); +} #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__) /* vec_vaddcuw */ diff --git a/clang/test/CodeGen/builtins-ppc-p8vector.c b/clang/test/CodeGen/builtins-ppc-p8vector.c index ea73cefc0706..07494c22f23b 100644 --- a/clang/test/CodeGen/builtins-ppc-p8vector.c +++ b/clang/test/CodeGen/builtins-ppc-p8vector.c @@ -84,6 +84,10 @@ void test1() { // CHECK-LE: add <2 x i64> // CHECK-PPC: error: call to 'vec_add' is ambiguous + res_vuc = vec_add_u128(vuc, vuc); +// CHECK: add <1 x i128> +// CHECK-LE: add <1 x i128> + /* vec_addc */ res_vsi = vec_addc(vsi, vsi); // CHECK: @llvm.ppc.altivec.vaddcuw @@ -99,6 +103,10 @@ void test1() { res_vux = vec_addc(vux, vux); // CHECK: @llvm.ppc.altivec.vaddcuq +// CHECK-LE: @llvm.ppc.altivec.vaddcuq + + res_vuc = vec_addc_u128(vuc, vuc); +// CHECK: @llvm.ppc.altivec.vaddcuq // CHECK-LE: @llvm.ppc.altivec.vaddcuq /* vec_adde */ @@ -108,11 +116,19 @@ void test1() { res_vux = vec_adde(vux, vux, vux); // CHECK: @llvm.ppc.altivec.vaddeuqm +// CHECK-LE: @llvm.ppc.altivec.vaddeuqm + + res_vuc = vec_adde_u128(vuc, vuc, vuc); +// CHECK: @llvm.ppc.altivec.vaddeuqm // CHECK-LE: @llvm.ppc.altivec.vaddeuqm /* vec_addec */ res_vsx = vec_addec(vsx, vsx, vsx); // CHECK: @llvm.ppc.altivec.vaddecuq +// CHECK-LE: @llvm.ppc.altivec.vaddecuq + + res_vuc = vec_addec_u128(vuc, vuc, vuc); +// CHECK: @llvm.ppc.altivec.vaddecuq // CHECK-LE: @llvm.ppc.altivec.vaddecuq /* vec_mergee */ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits