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

--- Comment #11 from Jeffrey A. Law <law at redhat dot com> ---
So could we reassociate the address arithmetic in match.pd so that we fold away
the pointer computation in favor of index adjustment in the ARRAY_REF?  Do we
have to worry about overflow in address reassociation?

Using the gimple from c#2:

  i.0_3 = i;
  _4 = i.0_3 * 4;
  _5 = (sizetype) _4;
  _6 = _5 + 4;
  _7 = &a[1] + _6;
  _9 = i.0_3 + 2;
  _10 = &a[_9];
  if (_7 != _10)


Transform it into:

  i.0_3 = i;
  temp = i.0_3 + 1 + 1;  /* +1 from pointer arith, +1 from array index ]
  _4 = i.0_3 * 4;        /* DEAD */
  _5 = (sizetype) _4;    /* DEAD */
  _6 = _5 + 4;           /* DEAD */
  _7 = &a[temp];
  _9 = i.0_3 + 2;
  _10 = &a[_9];
  if (_7 != _10)

That gives us a fighting chance to see that temp is equivalent to _9 and that
the ultimate addresses are equal.

Reply via email to