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


Richard Henderson <rth@redhat.com> writes:

| On Thu, Oct 07, 2004 at 03:49:45PM -0500, Gabriel Dos Reis wrote:
| > Richard Henderson <rth@redhat.com> 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.

Yes, but that was not the point I was making.

| 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.

My point was that it does not suffice that C1 and C2 be exactly
representable, we also need C3 not to overflow.

| If we were only concerned about overflow, we should be checking
| HONOR_INFINITIES instead of flag_unsafe_math_optimizations.

We're not only concerned about overflow.  See above for the point of
my remark.

-- Gaby


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