https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114700
--- Comment #7 from lin1.hu at intel dot com --- (In reply to Andrew Pinski from comment #5) > From match.pd: > /* 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 */ > (simplify > (minus (nop_convert1? (plus:c (nop_convert2? @0) @1)) @0) > (view_convert @1)) > (simplify > (minus (nop_convert1? (minus (nop_convert2? @0) @1)) @0) > (if (!ANY_INTEGRAL_TYPE_P (type) > || TYPE_OVERFLOW_WRAPS (type)) > (negate (view_convert @1)) > (view_convert (negate @1)))) > > Looks like missing a TYPE_OVERFLOW_SANITIZED check. OK, this looks like the same reason why z = c - y + a - c is not optimized.