https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92734
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- We have a set of special-case patterns for simple associations in match.pd, one for this case seems missing, like the group /* Match patterns that allow contracting a plus-minus pair irrespective of overflow issues. */ /* (A +- B) - A -> +- B */ /* (A +- B) -+ B -> A */ /* A - (A +- B) -> -+ B */ /* A +- (B -+ A) -> +- B */ closest match is /* CST1 - (CST2 - A) -> CST3 + A */ (simplify (minus CONSTANT_CLASS_P@1 (minus CONSTANT_CLASS_P@2 @0)) (with { tree cst = const_binop (MINUS_EXPR, type, @1, @2); } (if (cst && !TREE_OVERFLOW (cst)) (plus { cst; } @0)))) which "just" seems to lack a (convert? ...) around the inner minus. And yes, reassoc would be the pass to handle this, maybe in the very late if/when we decide to switch the IL to -fwapv semantics there.