[PowerPC] Use modulo arithmetic for vec_extract in altivec.h

These interfaces are not covered in the ELFv2 ABI but are rather
implemented to emulate those available in GCC/XLC. However, the
ones in the other compilers are documented to perform modulo
arithmetic on the element number. This patch just brings clang
inline with the other compilers at -O0 (with optimization, clang
already does the right thing).
This commit is contained in:
Nemanja Ivanovic 2021-03-01 19:23:26 -06:00
parent c35105055e
commit 38a34e207f
1 changed files with 30 additions and 28 deletions

View File

@ -12915,73 +12915,75 @@ vec_vxor(vector bool long long __a, vector bool long long __b) {
/* vec_extract */
static __inline__ signed char __ATTRS_o_ai vec_extract(vector signed char __a,
int __b) {
return __a[__b];
unsigned int __b) {
return __a[__b & 0xf];
}
static __inline__ unsigned char __ATTRS_o_ai
vec_extract(vector unsigned char __a, int __b) {
return __a[__b];
vec_extract(vector unsigned char __a, unsigned int __b) {
return __a[__b & 0xf];
}
static __inline__ unsigned char __ATTRS_o_ai vec_extract(vector bool char __a,
int __b) {
return __a[__b];
unsigned int __b) {
return __a[__b & 0xf];
}
static __inline__ signed short __ATTRS_o_ai vec_extract(vector signed short __a,
int __b) {
return __a[__b];
unsigned int __b) {
return __a[__b & 0x7];
}
static __inline__ unsigned short __ATTRS_o_ai
vec_extract(vector unsigned short __a, int __b) {
return __a[__b];
vec_extract(vector unsigned short __a, unsigned int __b) {
return __a[__b & 0x7];
}
static __inline__ unsigned short __ATTRS_o_ai vec_extract(vector bool short __a,
int __b) {
return __a[__b];
unsigned int __b) {
return __a[__b & 0x7];
}
static __inline__ signed int __ATTRS_o_ai vec_extract(vector signed int __a,
int __b) {
return __a[__b];
unsigned int __b) {
return __a[__b & 0x3];
}
static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector unsigned int __a,
int __b) {
return __a[__b];
unsigned int __b) {
return __a[__b & 0x3];
}
static __inline__ unsigned int __ATTRS_o_ai vec_extract(vector bool int __a,
int __b) {
return __a[__b];
unsigned int __b) {
return __a[__b & 0x3];
}
#ifdef __VSX__
static __inline__ signed long long __ATTRS_o_ai
vec_extract(vector signed long long __a, int __b) {
return __a[__b];
vec_extract(vector signed long long __a, unsigned int __b) {
return __a[__b & 0x1];
}
static __inline__ unsigned long long __ATTRS_o_ai
vec_extract(vector unsigned long long __a, int __b) {
return __a[__b];
vec_extract(vector unsigned long long __a, unsigned int __b) {
return __a[__b & 0x1];
}
static __inline__ unsigned long long __ATTRS_o_ai
vec_extract(vector bool long long __a, int __b) {
return __a[__b];
vec_extract(vector bool long long __a, unsigned int __b) {
return __a[__b & 0x1];
}
static __inline__ double __ATTRS_o_ai vec_extract(vector double __a, int __b) {
return __a[__b];
static __inline__ double __ATTRS_o_ai vec_extract(vector double __a,
unsigned int __b) {
return __a[__b & 0x1];
}
#endif
static __inline__ float __ATTRS_o_ai vec_extract(vector float __a, int __b) {
return __a[__b];
static __inline__ float __ATTRS_o_ai vec_extract(vector float __a,
unsigned int __b) {
return __a[__b & 0x3];
}
#ifdef __POWER9_VECTOR__