diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2016-07-20 10:18:01 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2016-07-20 10:18:01 +0000 |
commit | e3b9ee0645a62b0be69c31f8a45cfd2195545998 (patch) | |
tree | dd1f590f87c6eefaba0c436c14f71b1697138156 /clang/lib | |
parent | f345d40ae2a94a00cdb881934f6dae78e0dd0786 (diff) | |
download | bcm5719-llvm-e3b9ee0645a62b0be69c31f8a45cfd2195545998.tar.gz bcm5719-llvm-e3b9ee0645a62b0be69c31f8a45cfd2195545998.zip |
[X86][SSE] Reimplement SSE fp2si conversion intrinsics instead of using generic IR
D20859 and D20860 attempted to replace the SSE (V)CVTTPS2DQ and VCVTTPD2DQ truncating conversions with generic IR instead.
It turns out that the behaviour of these intrinsics is different enough from generic IR that this will cause problems, INF/NAN/out of range values are guaranteed to result in a 0x80000000 value - which plays havoc with constant folding which converts them to either zero or UNDEF. This is also an issue with the scalar implementations (which were already generic IR and what I was trying to match).
This patch changes both scalar and packed versions back to using x86-specific builtins.
It also deals with the other scalar conversion cases that are runtime rounding mode dependent and can have similar issues with constant folding.
Differential Revision: https://reviews.llvm.org/D22105
llvm-svn: 276102
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Headers/avxintrin.h | 4 | ||||
-rw-r--r-- | clang/lib/Headers/emmintrin.h | 9 | ||||
-rw-r--r-- | clang/lib/Headers/xmmintrin.h | 4 |
3 files changed, 8 insertions, 9 deletions
diff --git a/clang/lib/Headers/avxintrin.h b/clang/lib/Headers/avxintrin.h index 86bfdfb80c7..32e8546817b 100644 --- a/clang/lib/Headers/avxintrin.h +++ b/clang/lib/Headers/avxintrin.h @@ -2117,7 +2117,7 @@ _mm256_cvtps_pd(__m128 __a) static __inline __m128i __DEFAULT_FN_ATTRS _mm256_cvttpd_epi32(__m256d __a) { - return (__m128i)__builtin_convertvector((__v4df) __a, __v4si); + return (__m128i)__builtin_ia32_cvttpd2dq256((__v4df) __a); } static __inline __m128i __DEFAULT_FN_ATTRS @@ -2129,7 +2129,7 @@ _mm256_cvtpd_epi32(__m256d __a) static __inline __m256i __DEFAULT_FN_ATTRS _mm256_cvttps_epi32(__m256 __a) { - return (__m256i)__builtin_convertvector((__v8sf) __a, __v8si); + return (__m256i)__builtin_ia32_cvttps2dq256((__v8sf) __a); } static __inline double __DEFAULT_FN_ATTRS diff --git a/clang/lib/Headers/emmintrin.h b/clang/lib/Headers/emmintrin.h index c78d059f442..70d6d726110 100644 --- a/clang/lib/Headers/emmintrin.h +++ b/clang/lib/Headers/emmintrin.h @@ -417,8 +417,7 @@ _mm_cvtsd_si32(__m128d __a) static __inline__ __m128 __DEFAULT_FN_ATTRS _mm_cvtsd_ss(__m128 __a, __m128d __b) { - __a[0] = __b[0]; - return __a; + return (__m128)__builtin_ia32_cvtsd2ss((__v4sf)__a, (__v2df)__b); } static __inline__ __m128d __DEFAULT_FN_ATTRS @@ -444,7 +443,7 @@ _mm_cvttpd_epi32(__m128d __a) static __inline__ int __DEFAULT_FN_ATTRS _mm_cvttsd_si32(__m128d __a) { - return __a[0]; + return __builtin_ia32_cvttsd2si((__v2df)__a); } static __inline__ __m64 __DEFAULT_FN_ATTRS @@ -1707,7 +1706,7 @@ _mm_cvtsd_si64(__m128d __a) static __inline__ long long __DEFAULT_FN_ATTRS _mm_cvttsd_si64(__m128d __a) { - return __a[0]; + return __builtin_ia32_cvttsd2si64((__v2df)__a); } #endif @@ -1755,7 +1754,7 @@ _mm_cvtps_epi32(__m128 __a) static __inline__ __m128i __DEFAULT_FN_ATTRS _mm_cvttps_epi32(__m128 __a) { - return (__m128i)__builtin_convertvector((__v4sf)__a, __v4si); + return (__m128i)__builtin_ia32_cvttps2dq((__v4sf)__a); } /// \brief Returns a vector of [4 x i32] where the lowest element is the input diff --git a/clang/lib/Headers/xmmintrin.h b/clang/lib/Headers/xmmintrin.h index 3110e8babf9..99cddb0fac8 100644 --- a/clang/lib/Headers/xmmintrin.h +++ b/clang/lib/Headers/xmmintrin.h @@ -1350,7 +1350,7 @@ _mm_cvt_ps2pi(__m128 __a) static __inline__ int __DEFAULT_FN_ATTRS _mm_cvttss_si32(__m128 __a) { - return __a[0]; + return __builtin_ia32_cvttss2si((__v4sf)__a); } /// \brief Converts a float value contained in the lower 32 bits of a vector of @@ -1386,7 +1386,7 @@ _mm_cvtt_ss2si(__m128 __a) static __inline__ long long __DEFAULT_FN_ATTRS _mm_cvttss_si64(__m128 __a) { - return __a[0]; + return __builtin_ia32_cvttss2si64((__v4sf)__a); } /// \brief Converts two low-order float values in a 128-bit vector of |