https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80275
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
On the GCC 5 branch we go via

    case MINUS_EXPR:
      /* Pointer simplifications for subtraction, simple reassociations. */
...
          /* PTR0 - (PTR1 p+ A) -> (PTR0 - PTR1) - A, assuming PTR0 - PTR1
             simplifies. */
          else if (TREE_CODE (arg1) == POINTER_PLUS_EXPR)
            {
              tree arg10 = fold_convert_loc (loc, type,
                                             TREE_OPERAND (arg1, 0));
              tree arg11 = fold_convert_loc (loc, type,
                                             TREE_OPERAND (arg1, 1));
              tree tmp = fold_binary_loc (loc, MINUS_EXPR, type,
                                          fold_convert_loc (loc, type, arg0),
                                          arg10);
              if (tmp)
                return fold_build2_loc (loc, MINUS_EXPR, type, tmp, arg11);

and then simplify &MEM[(void *)&D.15614 + 12B] - &D.15614 via
ptr_difference_const.

On trunk the former is no longer in place and we directly fall through to
associate:

We can improve ptr_difference_const to catch this case.

Reply via email to