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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-03-20
           Keywords|                            |missed-optimization
            Version|unknown                     |10.0
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  Might be also a regression since POINTER_DIFF_EXPR introduction.

We have

   (simplify
    (pointer_diff (pointer_plus @@0 @1) (pointer_plus @0 @2))
    /* The second argument of pointer_plus must be interpreted as signed, and
       thus sign-extended if necessary.  */
    (with { tree stype = signed_type_for (TREE_TYPE (@1)); }
     /* Use view_convert instead of convert here, as POINTER_PLUS_EXPR
        second arg is unsigned even when we need to consider it as signed,
        we don't want to diagnose overflow here.  */
     (minus (convert (view_convert:stype @1))
            (convert (view_convert:stype @2)))))))

which triggers here but appearantly the resulting minus isn't simplified.

  _1 = n_5(D) * 8;
  b1_7 = a_6(D) + _1;
  _2 = n_5(D) + 18446744073709551615;
  _3 = _2 * 8;
  b2_8 = a_6(D) + _3;

and we need to simplify _1 - _3.  Possibly the excessive conversions above
mess with the constraint of CCP not wanting new stmts.  You can see what
forwprop does which applies all foldings possible and computes:

  _1 = n_5(D) * 8;
  _2 = n_5(D) + 18446744073709551615;
  _3 = _2 * 8;
  _11 = (signed long) _1;
  _12 = (signed long) _3;
  _4 = _11 - _12;
  _9 = (long unsigned int) _4;
  return _9;

I don't think we have match.pd patterns simplifying that.

Reply via email to