On 7/21/2026 2:29 PM, Andrea Pinski wrote:
We can sometimes combine comparisons that are trapping.
This adds that optimization to ifcombine; using combine_comparison
from fold-const to do most of the work.
This does not handle all cases though; mostly dealing with where we need an
inversion of the outer comparison and it does not invert is not currently
handled.
This will be handled later on as it needs some extra code added to
combine_comparisons.
Bootstrapped and tested on x86_64-linux-gnu.
PR tree-optimization/126138
gcc/ChangeLog:
* tree-ssa-ifcombine.cc (bb_no_side_effects_p): Don't reject GIMPLE_COND
that can trap.
(ifcombine_ifandif): Handle trapping inner conditional specially.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/fp-trapping-cmp-2.c: New test.
* gcc.dg/tree-ssa/fp-trapping-cmp-3.c: New test.
Signed-off-by: Andrea Pinski <[email protected]>
OK.
Jeff