This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch gcc-4.0 should not apply mathematical associative rules for addition or multiplication


On Oct 7, 2004, at 3:10 PM, Joseph S. Myers wrote:
On Thu, 7 Oct 2004, Dale Johannesen wrote:

Offhand it seems that the combination might be safe if C1 op C2 is
representable, and C1 and C2 both "move the result in the same direction",
i.e. both absolute values >1 or both <1 for multiplication, both positive or
both negative for addition and subtraction. (Obviously it's OK if one of
them is 0 but I assume this is handled elsewhere.) Does this seem right?

A previous discussion of this sort of thing mentioned the case of x * 0.25
== 0 but x * 0.5 == x so x * 0.5 * 0.5 != x * 0.25, for small x and
rounding towards positive infinity with -frounding-math.

OK. Did the previous discussion arrive at a rule for cases that *are* safe?


Adding Steve Peters, in Apple's numerics group, who understands this stuff.
Only fair since his bug report started the whole thing (3813473). Steve, the
issue is that people do not want to disallow folding
(x op C1) op C2
in cases where it safe to fold (for multiplication, C1==C2==2 has been
mentioned several times). Can we identify such cases?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]