This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: optimization request: (-a)*(-b) => a*b
- To: N8TM at aol dot com
- Subject: Re: optimization request: (-a)*(-b) => a*b
- From: Sylvain Pion <Sylvain dot Pion at sophia dot inria dot fr>
- Date: Thu, 4 Mar 1999 15:21:24 +0100
- Cc: egcs at egcs dot cygnus dot com
- References: <a05c8ce8.36de927b@aol.com>
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