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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
We only have e + (b - e):

/* Pattern match
     tem1 = (long) ptr1;
     tem2 = (long) ptr2;
     tem3 = tem2 - tem1;
     tem4 = (unsigned long) tem3;
     tem5 = ptr1 + tem4;
   and produce
     tem5 = ptr2;  */
(simplify 
  (pointer_plus @0 (convert?@2 (minus@3 (convert @1) (convert @0))))
  /* Conditionally look through a sign-changing conversion.  */
  (if (TYPE_PRECISION (TREE_TYPE (@2)) == TYPE_PRECISION (TREE_TYPE (@3))
       && ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (@1)))
            || (GENERIC && type == TREE_TYPE (@1))))
   @1))
(simplify
  (pointer_plus @0 (convert?@2 (pointer_diff@3 @1 @@0)))
  (if (TYPE_PRECISION (TREE_TYPE (@2)) >= TYPE_PRECISION (TREE_TYPE (@3)))
   (convert @1)))

Reply via email to