diff options
author | Nemanja Ivanovic <nemanja.i.ibm@gmail.com> | 2021-03-01 19:23:26 -0600 |
---|---|---|
committer | Nemanja Ivanovic <nemanja.i.ibm@gmail.com> | 2021-03-01 19:49:26 -0600 |
commit | 38a34e207f30747a4b0288d97ce67e422bf5f363 (patch) | |
tree | dc7d93c5719d6ea221cbd7ce376801e11efec273 /clang/lib | |
parent | c35105055ee4565ee6726d5b155538dd5c0307d3 (diff) | |
download | llvm-38a34e207f30747a4b0288d97ce67e422bf5f363.zip llvm-38a34e207f30747a4b0288d97ce67e422bf5f363.tar.gz llvm-38a34e207f30747a4b0288d97ce67e422bf5f363.tar.bz2 |
[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).
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Headers/altivec.h | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h index 4d50d47..402f3b3 100644 --- a/clang/lib/Headers/altivec.h +++ b/clang/lib/Headers/altivec.h @@ -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__ |