[Bug tree-optimization/37166] New: variable is still committed to stack even though it is not aliased

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Aug 19 19:20:00 GMT 2008


Testcase:
struct f { int a; };


int g(struct f *b, struct f *c)
{
  struct f g;
  if (!b) {
    b = &g;
    b->a = c->a + 1;
    c->a = c->a + 1;
  }
  else if (!c) {
    c = &g;
    c->a = b->a + 1;
    b->a = b->a + 1;
  }
  return c->a + b->a;
}
--- CUT ---
After some changes on the trunk, we get:
<bb 2>:
  if (b == 0B)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  g.a = [plus_expr] c->a + 1;
  prephitmp.13 = c->a + 1;
  c->a = prephitmp.13;
  prephitmp.25 = g.a;
  goto <bb 7>;

<bb 4>:
  if (c == 0B)
    goto <bb 6>;
  else
    goto <bb 5>;

<bb 5>:
  prephitmp.13 = c->a;
  prephitmp.25 = b->a;
  goto <bb 7>;

<bb 6>:
  g.a = [plus_expr] b->a + 1;
  prephitmp.25 = b->a + 1;
  b->a = prephitmp.25;
  prephitmp.13 = g.a;

<bb 7>:
  return prephitmp.25 + prephitmp.13;

--- CUT ---
Notice how g.a is still referenced.  This comes from 
  # b_1 = PHI <&g(3), b_3(D)(7), b_3(D)(5)>

Being in the IR after PRE even though b_1 is no longer referenced.
So for 32bit PPC we get a stack adjustment:
        stwu %r1,-32(%r1)
..
        addi %r1,%r1,32

Even though there is no need for this adjustment as nothing touches the stack
but the variable g is still being marked with TREE_ADDRESSABLE as evident by:
Partition 0: size 4 align 4
        g, offset 0
in the .expand dump.


-- 
           Summary: variable is still committed to stack even though it is
                    not aliased
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37166



More information about the Gcc-bugs mailing list