Currently LIM does not handle moving invariant PHIs.

void bar (int);
void foo (int n, int m)
{
  unsigned i;
  for (i = 0; i < n; ++i)
    {
      int x;
      if (m < 0)
        x = 1;
      else
        x = m;
      bar (x);
    }
}

we should move the computation of x out of the loop.

For simple cases like this, a single invariant PHI node controlled by
the predicate

  if (m_6(D) < 0)
    goto <bb 4>;
  else
    goto <bb 9>;

<bb 9>:
  goto <bb 5>;

<bb 4>:

<bb 5>:
  # x_2 = PHI <1(4), m_6(D)(9)>

we can hoist x_2 by inserting an assignment from a COND_EXPR.  Multiple
PHI nodes and/or not trivially empty intermediate blocks should be moved
as CFG pieces instead.

Thus hacking the simple case into LIM is the same as converting such
CFG pieces to COND_EXPRs similar to what if-conversion for the vectorizer
does.


-- 
           Summary: LIM should handle PHI nodes
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          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=43934

Reply via email to