This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, PR 44133] Preserve sane warnings when deleting loads in SRA
On Mon, 17 May 2010, Martin Jambor wrote:
> Hi,
>
> On Mon, May 17, 2010 at 11:28:05AM +0200, Richard Guenther wrote:
> >
>
> ...
>
> >
> > Are you sure that it helps even when you add another memory store
> > before the access in the testcase, like
> >
> > + /* { dg-do compile } */
> > + /* { dg-options "-O2 -Wall" } */
> > +
> > + struct S { int i, j; };
> > +
> > int x;
> > + int foo (int l)
> > + {
> > + struct S s;
> > x = 0;
> > + s.j = l - 22; /* { dg-warning ".s\.i. is used uninitialized" } */
> > + return s.i + s.j;
> > + }
>
> Yes, it still emits the same warning (still at the wrong line). Why
> should this matter?
>
> >
> > ? How does the function look like after SRA with your patch?
>
> Before early SRA it looks like:
>
> foo (int l)
> {
> struct S s;
> int D.2726;
> int D.2725;
> int D.2724;
> int D.2723;
>
> <bb 2>:
> x = 0;
> D.2723_2 = l_1(D) + -22;
> s.j = D.2723_2;
> D.2725_3 = s.i; // <-- this statement is removed and def-defs propagated
> D.2726_4 = s.j;
> D.2724_5 = D.2725_3 + D.2726_4;
> return D.2724_5;
>
> }
>
> The current (unpatched) early SRA transforms it into:
>
> foo (int l)
> {
> int s$j;
> struct S s;
> int D.2726;
> int D.2725;
> int D.2724;
> int D.2723;
>
> <bb 2>:
> x = 0;
> D.2723_2 = l_1(D) + -22;
> s$j_9 = D.2723_2;
> D.2726_4 = s$j_9;
> D.2724_5 = D.2726_4 + D.2725_8(D); // <-- this def-def is the problem
> return D.2724_5;
>
> }
>
> Whereas early SRA with the proposed patch produces:
>
> foo (int l)
> {
> int s$i;
> int s$j;
> struct S s;
> int D.2726;
> int D.2725;
> int D.2724;
> int D.2723;
>
> <bb 2>:
> x = 0;
> D.2723_2 = l_1(D) + -22;
> s$j_9 = D.2723_2;
> D.2726_4 = s$j_9;
> D.2724_5 = D.2726_4 + s$i_8(D);
> return D.2724_5;
>
> }
Ah, ok. I was confused by the non-renaming stuff.
The patch is ok.
Thanks,
Richard.