[Bug tree-optimization/126138] `fp0 == fp1 || fp0 CMP fp1` can be combined always even with trapping

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126138

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrea Pinski <[email protected]>:

https://gcc.gnu.org/g:7d781db9c3d5159386b1f645355955da5f844ec4

commit r17-2707-g7d781db9c3d5159386b1f645355955da5f844ec4
Author: Andrea Pinski <[email protected]>
Date:   Sat Jul 11 22:56:40 2026 -0700

    fold: Allow combining eq/ne with a trapping to get a trapping [PR126138]

    For `(i == j) || (i < j)` this can be combined to just `i <= j` without
    worrying about removal of a trap as a NaN would cause the the equal to be
    false which will cause not to short circuit and the trapping instruction
    will always be executed.

    `(i != j) && (i < j)` has the same reasoning.

    Bootstrapped and tested on x86_64-linux-gnu.

            PR tree-optimization/126138

    gcc/ChangeLog:

            * fold-const.cc (combine_comparisons): Allow eq to combine
            with || and ne combine with && if the original rcode was trapping
            and the new code is trapping.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/fp-trapping-cmp-1.c: New test.

    Signed-off-by: Andrea Pinski <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.