This is the mail archive of the
mailing list for the GCC project.
Re: Patch gcc-4.0 should not apply mathematical associative rules for addition or multiplication
On Thu, Oct 07, 2004 at 03:49:45PM -0500, Gabriel Dos Reis wrote:
> Richard Henderson <firstname.lastname@example.org> writes:
> | On Wed, Oct 06, 2004 at 05:05:08PM -0700, Fariborz Jahanian wrote:
> | > * tree-ssa-dom.c (unsafe_associative_fp_binop): New function.
> | > (simplify_rhs_and_lookup_avail_expr): Disallow associativity
> | > and constant folding of floating point MULT_EXPR/PLUS_EXPR
> | > expressions.
> | If you apply this, I'll immediately file a PR for a regression
> | and assign it to you.
> | You should allow
> | X op C1 op C2
> | to combine to
> | X op C3
> | if C1 op C2 is exactly representable.
> Only if C3 does not overflow, which is the root of the issue why this
> transformation is unsafe in general.
Well, overflow is a subset of "not exactly representable", yes.
But more than that, (X * 0.3 * 3) would not be folded because bits
would be lost off the least-significant end. Which is surely the
more serious folding error.
If we were only concerned about overflow, we should be checking
HONOR_INFINITIES instead of flag_unsafe_math_optimizations.