https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85974
--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> --- In match.pd (simplify - (pointer_diff (convert?@2 @0) (convert?@3 ADDR_EXPR@1)) + (pointer_diff (convert?@2 @0) (convert1?@3 ADDR_EXPR@1)) (that is, we can have only one cast, not just 0 or 2) and similarly for the adjacent transformation. I didn't check if that requires any other adjustment, just pointing out a likely place for a patch.