fabs() intrinsic totally broken in P4, as of 2002-02-11
Jan Hubicka
jh@suse.cz
Sun Feb 17 08:15:00 GMT 2002
> When compiled with -O2 -march=pentium4, the resulting executable takes "-1 2
> -3" to "3 3 3". The assembly output carefully loads a, b and c into
> xmm5, xmm4 and xmm3 respectively with movsd commands, loads
> the magic constant 0x8000000000000000 into xmm0 from the constants
> table, and then does
Wonderfull bug. I suspected abs to be buggy, but never tried multiple
of them. I wonder what caused this problem.
>
> andnpd %xmm3,%xmm0; sets xmm0 to fabs(xmm3)
>
> but then does *nothing* with xmm4 and xmm5, and stores *xmm0* in d, e and f
> before the printf call.
>
> ANDN is not a commutative operation, so this strategy would in any case
> require lots of reloads of the magic constant; I don't quite see why the
> compiler doesn't use the complement of the magic constant and normal AND
> instructions.
GCC does not internally understand the logicals on floats. It believes it
can anytime normalize the constant w/o getting different result.
When I first time tried, I used the flats to represent the constants and gcc
got around to normalize the magic complement resulting in pure nonsense.
Perhaps now when I model it as TImode constant, I should be more lucky. I will
check.
Thanks for important bugreport!
Honza
>
> Tom
More information about the Gcc
mailing list