On 7/21/2026 2:29 PM, Andrea Pinski wrote:
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 eq 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]>
OK.  Note that I think the ChangeLog entry has a type "and ne combine with eq" probably should have been ne combine with &&.

Jeff

Reply via email to