[PATCH] Make PRE PHI insertion use an already available PHI
Richard Guenther
rguenther@suse.de
Fri Aug 22 09:05:00 GMT 2008
On Thu, 21 Aug 2008, Daniel Berlin wrote:
> On Thu, Aug 21, 2008 at 10:14 AM, Richard Guenther <rguenther@suse.de> wrote:
> >
> > This makes us no longer rely on a second DOM pass for
> > gcc.dg/builtins-20.c. The case in question is
> >
> > extern double cos(double);
> > void test2(double x, double y)
> > {
> > if (cos(y<10 ? x : -y) != cos(y<10 ? x : y))
> > link_error ();
> > }
> >
> > which we don't fold directly but have to deal with during optimization.
> > PRE figures out that all is equivalent but produces
> >
> > <bb 4>:
> > # x_1 = PHI <x_5(D)(7), y_3(D)(3)>
> > # D.1955_15 = PHI <D.1955_14(7), D.1955_7(3)>
> > # prephitmp_22 = PHI <D.1955_14(7), D.1955_7(3)>
> > D.1960_10 = prephitmp_22;
> > if (D.1955_15 != D.1960_10)
>
> Actually, this makes no sense to me.
> If you have a phi node already for the value, it should have detected
> it as a full redundancy, not a partial one.
It only gets a fully redundant value after PHI-translation, but we
do not look up the translated PHI nor do we seed the VN with that
result (so you could argue again that SCCVN should be better at
value-numbering PHIs). The situation before PRE is:
test2 (double x, double y)
{
double D.1960;
double D.1955;
<bb 2>:
if (y_3(D) >= 1.0e+1)
goto <bb 3>;
else
goto <bb 7>;
<bb 3>:
D.1955_7 = cos (y_3(D));
<bb 4>:
# x_1 = PHI <x_5(D)(7), y_3(D)(3)>
# D.1955_15 = PHI <D.1955_14(7), D.1955_7(3)>
D.1960_10 = cos (x_1);
if (D.1955_15 != D.1960_10)
goto <bb 5>;
else
goto <bb 8>;
<bb 8>:
goto <bb 6>;
<bb 5>:
link_error ();
<bb 6>:
return;
<bb 7>:
D.1955_14 = cos (x_5(D));
goto <bb 4>;
}
and cos (x_1) is available in both predecessors but of course computes
a different value in both, so we would insert a prephitmp to merge
those two values. But this merge phi is available already.
Richard.
More information about the Gcc-patches
mailing list