https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98522
Bug ID: 98522
Summary: _mm_cvttps_pi32 and _mm_cvtps_pi32 raise spurious FP
exceptions
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: foom at fuhm dot net
Target Milestone: ---
This is a regression due to the MMX in SSE work in GCC10. As far as I can tell,
it affects only these two functions.
Example test, which should return 0, but instead throws SIGFPE:
#pragma stdc fenv_access
#define _GNU_SOURCE
#include <emmintrin.h>
#include <fenv.h>
__attribute__((noinline)) __m64 test(__m128 a) {
return _mm_cvtt_ps2pi(a);
}
int main() {
feenableexcept(FE_INVALID);
__m128 x = (__m128)(__m128i){0x0000000000000000LL, 0x7fffffffffffffffLL};
volatile __m64 y = test(x);
}
In GCC 10 and trunk, the function test is compiled to:
cvttps2dq xmm0, xmm0
ret
which will convert the upper 64 bits as well as the lower 64 bits -- and
therefore raises FP exceptions accordingly. But, it ought to be ignoring the
upper 64bits.