https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94665
--- Comment #12 from z.zhanghaijian at huawei dot com <z.zhanghaijian at huawei dot com> --- (In reply to Segher Boessenkool from comment #11) > Confirmed the comment 4 problem, on all archs. This is a very old bug. Ok to me, can this optimization change flag_unsafe_math_optimizations to flag_finite_math_only? Like the patch: diff --git a/gcc/combine.c b/gcc/combine.c index cff76cd3303..f394d8dfd03 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -6643,7 +6643,7 @@ simplify_if_then_else (rtx x) /* Look for MIN or MAX. */ - if ((! FLOAT_MODE_P (mode) || flag_unsafe_math_optimizations) + if ((! FLOAT_MODE_P (mode) || flag_finite_math_only) && comparison_p && rtx_equal_p (XEXP (cond, 0), true_rtx) && rtx_equal_p (XEXP (cond, 1), false_rtx) Can this fix the bug?