optimization request: (-a)*(-b) => a*b
Sylvain Pion
Sylvain.Pion@sophia.inria.fr
Thu Mar 4 06:22:00 GMT 1999
On Thu, Mar 04, 1999 at 09:02:35AM -0500, N8TM@aol.com wrote:
> In a message dated 3/4/99 2:48:36 AM Pacific Standard Time,
> Sylvain.Pion@sophia.inria.fr writes:
>
> << I also think the following kind of tests can be optimized:
> (-a)>0 => a<0 >>
> Many compilers lump such transformations in to their equivalent of gnu's
> option -ffast-math. The transformation is valid if we exclude the behavior of
> NaN values. I have avoided using such options because of the occasional bad
> effects, and because I have never been able to measure a performance
> improvement on this account.
Why is it false for NaN values ?
If a is a NaN, then -a is a NaN too, and all comparisons involving a NaN
return false (except (NaN == NaN) and (NaN != NaN)).
I am not speaking about optimizing all transformations that are valid
algebraically (those belong to -ffast-math), but only those that are
valid wrt IEEE 754.
For example: (-a)*b => -(a*b) is not valid, but (-a)*(-b) => a*b is.
It would be nice if we had them...
--
Sylvain
More information about the Gcc
mailing list