This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/37449] [4.4 Regression] calculix gets wrong answer for -O1 -ffast-math
- From: "rguenther at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Oct 2008 18:43:49 -0000
- Subject: [Bug tree-optimization/37449] [4.4 Regression] calculix gets wrong answer for -O1 -ffast-math
- References: <bug-37449-4503@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #23 from rguenther at suse dot de 2008-10-15 18:43 -------
Subject: Re: [4.4 Regression] calculix gets
wrong answer for -O1 -ffast-math
On Wed, 15 Oct 2008, rguenther at suse dot de wrote:
> ------- Comment #22 from rguenther at suse dot de 2008-10-15 18:33 -------
> Subject: Re: [4.4 Regression] calculix gets
> wrong answer for -O1 -ffast-math
>
> On Wed, 15 Oct 2008, dberlin at dberlin dot org wrote:
>
> > ------- Comment #21 from dberlin at gcc dot gnu dot org 2008-10-15 17:55 -------
> > Subject: Re: [4.4 Regression] calculix gets wrong answer for -O1 -ffast-math
> >
> > >
> > > It already does (I fixed that recently), but we only phi-translate during
> > > insertion and we
> > > don't insert for that case, as obviously there is no partial redundancy.
> >
> > True, but if it discovered all the new phi arguments would be constant
> > it used to create a new phi node with the new constant values and let
> > eliminate replace the old calculation with the new phi node.
> >
> > Maybe it only did this if all the constants ended up the same value,
> > but it would be trivial to do it if all the arguments are constant,
> > regardless of whether they are the same value.
> > :)
>
> Well, we already do for
>
> int foo (int b)
> {
> double i;
> if (b)
> i = 4;
> else
> i = 9;
> return __builtin_sqrt(i);
> }
>
> <bb 4>:
> # i_1 = PHI <4.0e+0(5), 9.0e+0(3)>
> # prephitmp.11_7 = PHI <2.0e+0(5), 3.0e+0(3)>
> # prephitmp.12_8 = PHI <2(5), 3(3)>
> D.1238_5 = prephitmp.11_7;
> D.1237_6 = prephitmp.12_8;
> return D.1237_6;
Ok, for return __builtin_pow (i, i) it doesn't work because we
do not register phi-translations that result in constants (translating
i does) and then we run into the if (seen) guard and fail to
phi-translate.
Either we should register phi-translations for them or not do that
seen test for expr->kind == NAME (it shouldn't recurse for that, no?).
Richard.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37449