Dead code elimination of dead structure assignments in gcc

Reva Cuthbertson reva@cup.hp.com
Wed Jan 23 03:59:00 GMT 2002


I'm sorry.  I should have specified that I'm seeing this with a compiler
I built off of the mainline sources (which I assume will become gcc 3.1).
We grabbed the sources sometime late in December so maybe we need
to update?  Is this fixed on the mainline?

Thanks for pointing this out!

Reva


Daniel Berlin wrote:

> What version of gcc?
> Improved structure tracking and whatnot is on the mainline (but not in
> 3.0), so it's important to note which version you are seeing this
> behavior with.
> On Tue, 22 Jan 2002, Reva Cuthbertson wrote:
>
> > Hello,
> >
> >     I'm looking at how well gcc does with dead code elimination on IA-64
> >
> > and I'm seeing some problems with structures.  In particular, I have the
> >
> > following program:
> >
> > #include <stdio.h>
> > main()
> > {
> >   struct {
> >     int i1;
> >     int i2;
> >     int i3;
> >     int i4;
> >     int i5;
> >     int i6;
> >   } s;
> >   int j;
> >
> >   j = scanf("%d\n",&j);
> >   if (j == 1)
> >     s.i1 = 1111;
> >   if (j == 2)
> >     s.i2 = 2222;
> >   if (j == 3)
> >     s.i3 = 3333;
> >   if (j == 4)
> >     s.i4 = 4444;
> >   if (j == 5)
> >     s.i5 = 5555;
> >   if (j == 6)
> >     s.i6 = 6666;
> >   return;
> > }
> >
> >     All of the code (after scanf) should be dead code and eliminated.
> > However, when I compile the program with -O2, gcc is still generating
> > code for the if statements and for the stores into the structure.
> >
> >     If I change the program slightly so I'm just using integers
> > instead of a structure containing integers, all the dead code is
> > eliminated.  Any ideas as to why this is happening?  I've been looking
> > at propagate_block() and insn_dead_p() in flow.c to find out why
> > the code is not considered dead, but I'm not familiar enough
> > with these routines to understand why gcc does not consider the
> > code dead.   Is this a known problem with structures?
> >
> >
> > Thanks!
> >
> > Reva Cuthbertson
> > reva@cup.hp.com
> >



More information about the Gcc mailing list