This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR 15454: wrong code due to tree constant propagation
On Mon, 2004-05-17 at 10:37, Steven Bosscher wrote:
> On May 17, 2004 04:23 PM, Jason Merrill <jason@redhat.com> wrote:
>
> > On Mon, 17 May 2004 09:13:40 +0200, Steven Bosscher <stevenb@suse.de> wrote:
> >
> > > I believe we should assume that variables without an initializing
> > > statement are VARYING.
> >
> > No, uninitialized variables are undefined. The bug here is that we are
> > pretending that CHAIN is uninitialized, when in fact it is passed as an
> > argument. It should be handled just like any other parm.
>
> ... and we treat other params as VARYING (see how we deal with a
> PARM_DECL in get_default_value).
>
Yes, because they can be used without a previous initialization. For
regular locals what happens is that if you assume them VARYING, you will
never be able to raise their value when applying the meet operator.
Here's an admittedly contrived example: We should optimize foo() to
'return 9;'. But if we assume locals to be VARYING instead of
UNDEFINED, we will 'return b;'.
-------------------------------------------------------------------------
foo(int i)
{
int a, b;
if (i > 10)
goto m;
l:
if (a > 5)
b = a + 3;
else
b = 9;
m:
a = 6;
i++;
if (i < 10)
goto l;
return b;
}
main ()
{
foo (11);
}
-------------------------------------------------------------------------
I would first try to make CHAIN a PARM_DECL. Could you also add a
comment in get_default_value about this and add a tree-ssa scan test
case with this program? IIRC, optimistically assuming UNDEFINED is
recommended in the SCCP paper.
Diego.