[PATCH, middle-end, i386]: reciprocal rsqrt pass + full recip x86 backend support
Bradley Lucier
lucier@math.purdue.edu
Sat Jun 16 12:33:00 GMT 2007
You wrote:
> gcc -O2 -msse2 -mfpmath=sse -ffast-math equal.c
> ./a.out
> 0x1p+0
> 0x1p+0 0x1p+0 1
>
> gcc -O2 -msse2 -mfpmath=sse -ffast-math -mrecip equal.c
> ./a.out
> 0x1.fffffep-1
> 0x1p+0 0x1.fffffep-1 0
>
> Actually, the recip pass is OK, it is just a precision problem. This
> is why -mrecip should stay separate option, not included in
> -ffast-math...
-ffast-math does other things to code that sometimes cause even
bigger errors than -mrecip.
I think -ffast-math should turn on -mrecip (and similar
optimizations) if available, and then they can be turned off with
-ffast-math -mno-recip
if needed.
The original reporter really shouldn't have been using -ffast-math or
-mrecip if he was comparing floating-point values for equality.
(There are many valid reasons to compare floating-point values for
equality, but then one should try to have precisely-defined floating-
point arithmetic.)
I was impressed with the results of this optimization.
I'm CC'ing Roger Sayle in the hope that he weighs in with his opinion.
Brad
More information about the Gcc-patches
mailing list