[Bug tree-optimization/29738] New: Missed constant propagation into loops

rguenth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Nov 6 11:01:00 GMT 2006


For the following testcase

int i;
void foo (void);
void bar (void)
{
  int j;
  i = 0;
  for (j = 0; j < 10000; j++)
    if (i)
      foo ();
}

we cannot see that foo is never called and so the loop is empty.  The problem
is that i is part of the loop evolution and so appears in a PHI node so we
cannot figure out i is zero:

<bb 2>:
  #   i_3 = V_MUST_DEF <i_2>;
  i = 0;

  # NONLOCAL.6_19 = PHI <NONLOCAL.6_9(5), NONLOCAL.6_11(2)>;
  # i_18 = PHI <i_7(5), i_3(2)>;
  # j_17 = PHI <j_6(5), 0(2)>;
<L0>:;
  #   VUSE <i_18>;
  i.0_5 = i;
  if (i.0_5 != 0) goto <L1>; else goto <L2>;

<L1>:;
  #   i_12 = V_MAY_DEF <i_18>;
  #   NONLOCAL.6_13 = V_MAY_DEF <NONLOCAL.6_19>;
  foo ();

  # NONLOCAL.6_9 = PHI <NONLOCAL.6_19(3), NONLOCAL.6_13(4)>;
  # i_7 = PHI <i_18(3), i_12(4)>;
<L2>:;
  j_6 = j_17 + 1;
  if (j_6 <= 9999) goto <L0>; else goto <L4>;


I have no idea what optimization could catch this, though ;)


-- 
           Summary: Missed constant propagation into loops
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list