[Bug tree-optimization/52081] New: Missed tail merging with pure calls

vries at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Feb 1 10:24:00 GMT 2012


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

             Bug #: 52081
           Summary: Missed tail merging with pure calls
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vries@gcc.gnu.org


pr51879-12.c:
...
__attribute__((pure)) int bar (int);
__attribute__((pure)) int bar2 (int);
void baz (int);

int x, z;

void
foo (int y)
{
  int a = 0;
  if (y == 6)
    {
      a += bar (7);
      a += bar2 (6);
    }
  else
    {
      a += bar2 (6);
      a += bar (7);
    }
  baz (a);
}
...

When compiling at -O2, pr51879-12.c.094t.pre looks like this:
...
  # BLOCK 3 freq:1991
  # PRED: 2 [19.9%]  (true,exec)
  # VUSE <.MEMD.1722_12(D)>
  # USE = nonlocal escaped 
  D.1717_4 = barD.1703 (7);
  # VUSE <.MEMD.1722_12(D)>
  # USE = nonlocal escaped 
  D.1718_6 = bar2D.1705 (6);
  aD.1713_7 = D.1717_4 + D.1718_6;
  goto <bb 5>;
  # SUCC: 5 [100.0%]  (fallthru,exec)

  # BLOCK 4 freq:8009
  # PRED: 2 [80.1%]  (false,exec)
  # VUSE <.MEMD.1722_12(D)>
  # USE = nonlocal escaped 
  D.1720_8 = bar2D.1705 (6);
  # VUSE <.MEMD.1722_12(D)>
  # USE = nonlocal escaped 
  D.1721_10 = barD.1703 (7);
  aD.1713_11 = D.1720_8 + D.1721_10;
  # SUCC: 5 [100.0%]  (fallthru,exec)

  # BLOCK 5 freq:10000
  # PRED: 3 [100.0%]  (fallthru,exec) 4 [100.0%]  (fallthru,exec)
  # aD.1713_1 = PHI <aD.1713_7(3), aD.1713_11(4)>
  # .MEMD.1722_13 = VDEF <.MEMD.1722_12(D)>
  # USE = nonlocal 
  # CLB = nonlocal 
  bazD.1707 (aD.1713_1);
  # VUSE <.MEMD.1722_13>
  return;
...

Value numbering numbers the two phi arguments a_7 and a_11 the same so the
problem is not in value numbering:
...
Setting value number of a_11 to a_7 (changed)
...



More information about the Gcc-bugs mailing list