https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91384
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> --- The local gimple transform is not right or wrong, it depends on the surroundings and unless we have a way to assess those in a good way doing it in one or the other way is going to hurt either case. The usual "fix" is to stick single-use restrictions onto the patterns involving uses in compares, we're not very consistent with that. Like the following diff --git a/gcc/match.pd b/gcc/match.pd index 43bacb4f68e..c5582021b0e 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -4503,10 +4503,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))) (scmp @0 @1))) (simplify - (cmp (negate @0) CONSTANT_CLASS_P@1) + (cmp (negate@2 @0) CONSTANT_CLASS_P@1) (if (FLOAT_TYPE_P (TREE_TYPE (@0)) || (ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0)) - && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)))) + && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0)) + && single_use (@2))) (with { tree tem = const_unop (NEGATE_EXPR, TREE_TYPE (@0), @1); } (if (tem && !TREE_OVERFLOW (tem)) (scmp @0 { tem; }))))))