[PowerPC] Support for vector bool int128 on vector comparison builtins

This patch implements support for the type vector bool int128
for arguments on vector comparison builtins listed below,
which would otherwise crash due to ambiguity.

The following builtins are added:

vec_all_eq (vector bool __int128, vector bool __int128)
vec_all_ne (vector bool __int128, vector bool __int128)
vec_any_eq (vector bool __int128, vector bool __int128)
vec_any_ne (vector bool __int128, vector bool __int128)
vec_cmpne(vector bool __int128 a, vector bool __int128 b)
vec_cmpeq(vector bool __int128 a, vector bool __int128 b)

Differential revision: https://reviews.llvm.org/D110084
This commit is contained in:
Albion Fung 2021-09-21 15:46:30 -05:00
parent 52832cd917
commit b93359ea3f
2 changed files with 74 additions and 0 deletions

View File

@ -1810,6 +1810,11 @@ vec_cmpeq(vector unsigned __int128 __a, vector unsigned __int128 __b) {
return (vector bool __int128)__builtin_altivec_vcmpequq(
(vector bool __int128)__a, (vector bool __int128)__b);
}
static __inline__ vector bool __int128 __ATTRS_o_ai
vec_cmpeq(vector bool __int128 __a, vector bool __int128 __b) {
return (vector bool __int128)__builtin_altivec_vcmpequq(__a, __b);
}
#endif
#ifdef __POWER9_VECTOR__
@ -1887,6 +1892,11 @@ vec_cmpne(vector signed __int128 __a, vector signed __int128 __b) {
return (vector bool __int128) ~(__builtin_altivec_vcmpequq(
(vector bool __int128)__a, (vector bool __int128)__b));
}
static __inline__ vector bool __int128 __ATTRS_o_ai
vec_cmpne(vector bool __int128 __a, vector bool __int128 __b) {
return (vector bool __int128) ~(__builtin_altivec_vcmpequq(__a, __b));
}
#endif
/* vec_cmpnez */
@ -14870,6 +14880,11 @@ static __inline__ int __ATTRS_o_ai vec_all_eq(vector unsigned __int128 __a,
vector unsigned __int128 __b) {
return __builtin_altivec_vcmpequq_p(__CR6_LT, __a, __b);
}
static __inline__ int __ATTRS_o_ai vec_all_eq(vector bool __int128 __a,
vector bool __int128 __b) {
return __builtin_altivec_vcmpequq_p(__CR6_LT, __a, __b);
}
#endif
/* vec_all_ge */
@ -15815,6 +15830,11 @@ static __inline__ int __ATTRS_o_ai vec_all_ne(vector unsigned __int128 __a,
vector unsigned __int128 __b) {
return __builtin_altivec_vcmpequq_p(__CR6_EQ, __a, __b);
}
static __inline__ int __ATTRS_o_ai vec_all_ne(vector bool __int128 __a,
vector bool __int128 __b) {
return __builtin_altivec_vcmpequq_p(__CR6_EQ, __a, __b);
}
#endif
/* vec_all_nge */
@ -16104,6 +16124,11 @@ static __inline__ int __ATTRS_o_ai vec_any_eq(vector unsigned __int128 __a,
vector unsigned __int128 __b) {
return __builtin_altivec_vcmpequq_p(__CR6_EQ_REV, __a, __b);
}
static __inline__ int __ATTRS_o_ai vec_any_eq(vector bool __int128 __a,
vector bool __int128 __b) {
return __builtin_altivec_vcmpequq_p(__CR6_EQ_REV, __a, __b);
}
#endif
/* vec_any_ge */
@ -17079,6 +17104,11 @@ static __inline__ int __ATTRS_o_ai vec_any_ne(vector unsigned __int128 __a,
vector unsigned __int128 __b) {
return __builtin_altivec_vcmpequq_p(__CR6_LT_REV, __a, __b);
}
static __inline__ int __ATTRS_o_ai vec_any_ne(vector bool __int128 __a,
vector bool __int128 __b) {
return __builtin_altivec_vcmpequq_p(__CR6_LT_REV, __a, __b);
}
#endif
/* vec_any_nge */

View File

@ -19,6 +19,7 @@ vector signed long long vslla, vsllb;
vector unsigned long long vulla, vullb, vullc;
vector signed __int128 vsi128a, vsi128b, vsi128c;
vector unsigned __int128 vui128a, vui128b, vui128c;
vector bool __int128 vbi128a, vbi128b;
vector float vfa, vfb;
vector double vda, vdb;
float fa;
@ -1637,6 +1638,13 @@ vector bool __int128 test_vec_cmpeq_u128(void) {
return vec_cmpeq(vui128a, vui128b);
}
vector bool __int128 test_vec_cmpeq_bool_int128(void) {
// CHECK-LABEL: @test_vec_cmpeq_bool_int128(
// CHECK: call <1 x i128> @llvm.ppc.altivec.vcmpequq(<1 x i128>
// CHECK-NEXT: ret <1 x i128>
return vec_cmpeq(vbi128a, vbi128b);
}
vector bool __int128 test_vec_cmpne_s128(void) {
// CHECK-LABEL: @test_vec_cmpne_s128(
// CHECK: call <1 x i128> @llvm.ppc.altivec.vcmpequq(<1 x i128>
@ -1653,6 +1661,14 @@ vector bool __int128 test_vec_cmpne_u128(void) {
return vec_cmpne(vui128a, vui128b);
}
vector bool __int128 test_vec_cmpne_bool_int128(void) {
// CHECK-LABEL: @test_vec_cmpne_bool_int128(
// CHECK: call <1 x i128> @llvm.ppc.altivec.vcmpequq(<1 x i128>
// CHECK-NEXT: %neg.i = xor <1 x i128> %4, <i128 -1>
// CHECK-NEXT: ret <1 x i128>
return vec_cmpne(vbi128a, vbi128b);
}
vector bool __int128 test_vec_cmpgt_s128(void) {
// CHECK-LABEL: @test_vec_cmpgt_s128(
// CHECK: call <1 x i128> @llvm.ppc.altivec.vcmpgtsq(<1 x i128>
@ -1727,6 +1743,13 @@ int test_vec_any_eq_s128(void) {
return vec_any_eq(vsi128a, vsi128b);
}
int test_vec_any_eq_bool_int128(void) {
// CHECK-LABEL: @test_vec_any_eq_bool_int128(
// CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 1, <1 x i128> %2, <1 x i128> %3)
// CHECK-NEXT: ret i32
return vec_any_eq(vbi128a, vbi128b);
}
int test_vec_any_ne_s128(void) {
// CHECK-LABEL: @test_vec_any_ne_s128(
// CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 3, <1 x i128> %2, <1 x i128> %3)
@ -1741,6 +1764,13 @@ int test_vec_any_ne_u128(void) {
return vec_any_ne(vui128a, vui128b);
}
int test_vec_any_ne_bool_int128(void) {
// CHECK-LABEL: @test_vec_any_ne_bool_int128(
// CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 3, <1 x i128> %2, <1 x i128> %3)
// CHECK-NEXT: ret i32
return vec_any_ne(vbi128a, vbi128b);
}
int test_vec_any_lt_s128(void) {
// CHECK-LABEL: @test_vec_any_lt_s128(
// CHECK: call i32 @llvm.ppc.altivec.vcmpgtsq.p(i32 1, <1 x i128> %2, <1 x i128> %3)
@ -1811,6 +1841,13 @@ int test_vec_all_eq_u128(void) {
return vec_all_eq(vui128a, vui128b);
}
int test_vec_all_eq_bool_int128(void) {
// CHECK-LABEL: @test_vec_all_eq_bool_int128
// CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 2, <1 x i128> %2, <1 x i128> %3)
// CHECK-NEXT: ret i32
return vec_all_eq(vbi128a, vbi128b);
}
int test_vec_all_ne_s128(void) {
// CHECK-LABEL: @test_vec_all_ne_s128(
// CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 0, <1 x i128> %2, <1 x i128> %3)
@ -1825,6 +1862,13 @@ int test_vec_all_ne_u128(void) {
return vec_all_ne(vui128a, vui128b);
}
int test_vec_all_ne_bool_int128(void) {
// CHECK-LABEL: test_vec_all_ne_bool_int128
// CHECK: call i32 @llvm.ppc.altivec.vcmpequq.p(i32 0, <1 x i128> %2, <1 x i128> %3)
// CHECK-NEXT: ret i32
return vec_all_ne(vbi128a, vbi128b);
}
int test_vec_all_lt_s128(void) {
// CHECK-LABEL: @test_vec_all_lt_s128(
// CHECK: call i32 @llvm.ppc.altivec.vcmpgtsq.p(i32 2, <1 x i128> %2, <1 x i128> %3)