optimization request: (-a)*(-b) => a*b

Sylvain Pion Sylvain.Pion@sophia.inria.fr
Wed Mar 31 23:46:00 GMT 1999


On Thu, Mar 04, 1999 at 11:39:09AM +0000, Nathan Sidwell wrote:
> Sylvain Pion wrote:
> > While I am at it, I also think the following kind of tests can be optimized:
> > (-a)>0  => a<0
> > 
> > Am I right ?  Is it doable ?
> Depends on what the type and representation of a is.
> 
> If it is a floating point type with ieee representation, there is a +0 and a
> -0. ieee semantics are a bit strange here and there is some interaction with
> rounding modes IIR. It depends on how closely your trying to get ieee
> semantics.

I want full IEEE 754 semantics.
AFAIK, ieee says that -0 and +0 are not distinguishable by floating point
arithmetic comparisons (but they are distinguishable by there storage in
memory).  I'm totally aware of the rounding modes, I work with them every day.
I don't see any problem here, if you have a counter example, please show it.


> If you're happy changing the semantics of overflowing signed arithmetic from
> implentation defined to undefined, then the suggested optimization is ok.

I don't want to break semantics, not at all.  You are right for the integral
case, my proposed optimizations are not valid because the integer set is not
symetric against 0 :-(.

I still think they are valid for IEEE 754 though.

-- 
Sylvain



More information about the Gcc mailing list