https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128795
Igor Shevlyakov <ishevlyakov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2026-11-21
--- Comment #1 from Igor Shevlyakov <ishevlyakov at gcc dot gnu.org> ---
Confirmed on trunk (r17-6561-g12a68f71e251) with a sparc64-linux-gnu cross
cc1: at -O2 -fno-trapping-math, f compiles to just fmovd %f2, %f0. The
same happens with the condition written as UNEQ directly,
double
f (double a, double b)
{
return !__builtin_islessgreater (a, b) ? a : b;
}
where simplify_if_then_else reaches known_cond (true_rtx, UNEQ, a, b) for
the true arm, so it is not specific to reversing LTGT for the false arm.
With default flags both forms are correct on trunk only because no
conditional move is formed for them since r17-5585 (PR122307); releases
fail with default flags.
fold_cond_expr_with_comparison replaces A UNEQ B ? A : B by B only under
!HONOR_SIGNED_ZEROS and !HONOR_NANS; known_cond's UNEQ case needs the
same two conditions.
Other targets do not show it (GCC 16.2 on Compiler Explorer, both forms,
-O2 with and without -fno-trapping-math). On x86-64 and x87 the
comparison is (unspec [(compare ...)] UNSPEC_NOTRAP), so the substituted
condition does not expose A and B. loongarch64 inverts the condition for
fsel. aarch64, mips64r2, ppc64le, s390x, riscv64 and arm compare and
branch.