This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch gcc-4.0 should not apply mathematical associative rules for addition or multiplication
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: roger at eyesopen dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 8 Oct 04 06:52:22 EDT
- Subject: Re: Patch gcc-4.0 should not apply mathematical associative rules for addition or multiplication
I think that converting (x * C1) * C2 into x * (C1 * C2) is "unsafe"
in IEEE arithmetic even if C1 and C2 are powers of two, and C1*C2 is
perfectly representable (as returned by real.c's do_multiply).
Consider C1 = 2.0, C2 = 0.5 and x = FLT_MAX.
Is it really *required* to overflow if an intermediate result overflows but
the result of the entire operation is representable? Certainly Ada allows
producing the "correct" result in that case and so the optimization is
valid. Do the other language standards forbid it?