https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122653

            Bug ID: 122653
           Summary: SCEV does not handle POINTER_DIFF_EXPR
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

extern char a[];
int foo ()
{
  int cnt = 0;
  char *aend = a + 32;
  char *a0 = a;
  do
    {
      a0 = a0 + 16;
      cnt++;
    }
  while (aend - a0 > 12);
  return cnt;
}

for this testcase we fail number of iteration analysis because

  <bb 3> [local count: 1073741824]:
  # a0_3 = PHI <&a(2), a0_4(5)>
  ...
  a0_4 = a0_3 + 16;
  ...
  _1 = &MEM <char[<unknown>]> [(void *)&a + 32B] - a0_4;
  if (_1 > 12)

we already fail to analyze the scalar evolution of _1.  SCEV handles
MINUS_EXPR, but only when the SSA cycle is on the first operand, but
not POINTER_DIFF_EXPR.  So a similar case can be probably constructed
with integer MINUS_EXPR.

Reply via email to