This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PING][PATCH] Fix PR 28684
- From: Richard Guenther <rguenther at suse dot de>
- To: Revital1 Eres <ERES at il dot ibm dot com>
- Cc: Roger Sayle <roger at eyesopen dot com>, Dorit Nuzman <DORIT at il dot ibm dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 6 Nov 2006 10:24:52 +0100 (CET)
- Subject: Re: [PING][PATCH] Fix PR 28684
- References: <OFCF1A5DFF.E90C80B6-ONC225721E.00314F8A-C225721E.00320C0D@il.ibm.com>
On Mon, 6 Nov 2006, Revital1 Eres wrote:
>
> > In some of the cases you do
> >
> > @@ -1107,7 +1107,7 @@
> >
> > case MINUS_EXPR:
> > /* - (A - B) -> B - A */
> > - if ((! FLOAT_TYPE_P (type) || flag_unsafe_math_optimizations)
> > + if ((! FLOAT_TYPE_P (type) || flag_associative_math)
> > && reorder_operands_p (TREE_OPERAND (t, 0), TREE_OPERAND (t,
> > 1)))
> > return fold_build2 (MINUS_EXPR, type,
> > TREE_OPERAND (t, 1), TREE_OPERAND (t, 0));
> >
> > or
> >
> > @@ -971,7 +971,7 @@
> >
> > case MINUS_EXPR:
> > /* We can't turn -(A-B) into B-A when we honor signed zeros. */
> > - return (! FLOAT_TYPE_P (type) || flag_unsafe_math_optimizations)
> > + return (! FLOAT_TYPE_P (type) || flag_associative_math)
> > && reorder_operands_p (TREE_OPERAND (t, 0),
> > TREE_OPERAND (t, 1));
> >
> > where the comment already suggests this should read ||
> !HONOR_SIGNED_ZEROS
> > (TYPE_MODE (type)). There are machines without signed zeros out there
> > which will benefit from this even without flag_associative_math.
> >
> > Richard.
> >
>
> But the transformation is re-association; Can we apply it without the flag
> (just by checking
> that we are not honoring signed zeros)?
It depends on how we violate IEEE math by doing the re-association. If
we re-associate a + (b + c) to (a + b) + c we may change rounding
behavior, if we re-order a + b to b + a we don't change rounding and
behavior with signed zeros doesn't change. If we re-order (not
reassociate!) - (a - b) to b - a, we change rounding behavior (at least
with rounding towards infinity for example) _and_ change behavior with
signed zeros.
So you are right, we need flag_associative_math here due to the rounding
issues (which is basically all flag_associative_math is about, in addition
to the signed zero stuff).
It's just all nicely twisted, so we need some very good documentation on
the flags.
flag_reciprocal_math is all about transforming a / b to a * (1/b), so
if we here do something like a * (b / c) to (a * b) / c, that is
re-association, not reciprocal stuff.
Richard.
--
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs