https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78546
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> --- Testing diff --git a/gcc/match.pd b/gcc/match.pd index 2d4e019..9e5df64 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1216,6 +1216,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (cst && !TREE_OVERFLOW (cst)) (minus { cst; } @0))))) + /* CST - (CST - A) -> CST - 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)) + (minus { cst; } @0)))) + /* ~A + A -> -1 */ (simplify (plus:c (bit_not @0) @0) for the optimization regression.