On Fri, Oct 2, 2026 at 9:11 AM Jeff Law <[email protected]> wrote:
>
>
>
> On 9/29/26 4:24 AM, Richard Biener wrote:
> > From: Gemini Reviewer <gemini@localhost>
> >
> > When combining conditions ifcombine_ifandif passes inner_cond_code as the
> > first comparison and outer_cond_code as the second to
> > maybe_fold_and_comparisons and maybe_fold_and_comparisons calls
> > and_comparisons_1 with both comparison orders.  Both defeats preserving
> > IEEE exceptions of trapping outer comparisons which combine_comparisons
> > handles, but only when the order of the comparisons is preserved correctly.
> >
> > This disables some optimization in and_comparisons_1 which only looks
> > through SSA defs for the first comparison.  This requires larger
> > refactoring and the overall design seems dubious with recursions
> > going in ways that with the swapping look exponential.
> >
> > Bootstrapped and tested on x86_64-unknown-linux-gnu.
> >
> > OK?
> >
> > Thanks,
> > Richard.
> >
> >       PR tree-optimization/53805
> >       * tree-ssa-ifcombine.cc (ifcombine_ifandif): Pass comparisons
> >       in the correct order.
> >       * gimple-fold.cc (and_comparisons_1): Add FIXME comment.
> >       (maybe_fold_and_comparisons): Do not call and_comparisons_1 with
> >       swapped comparisons.
> >
> >       * gcc.dg/tree-ssa/fp-trapping-cmp-6.c: New testcase
> >       * gcc.dg/tree-ssa/fp-trapping-cmp-7.c: Likewise.
> I kind of expected some fallout for the potential missed optimization
> case, but I guess it never got covered.

I suspect most of the fallout (which would have happened) was fixed by
r17-2707-g7d781db9c3d515, r17-2708-gea33efbbdcf697, and
r17-2709-gde8be0eb05d951 (that was the reasoning for those 3 commits
even to fix some of the fallout there).
There is still one more potential missed optimization I was looking at
with respect to ifcombining here was when invert_tree_comparison
returned ERROR_MARK.  Which will show up due to allowing early phiopt
of comparisons and/or the forwprop patch for combing phis with single
use stmts (yes both cause a similar fallout).

>
> OK for the trunk.
> jeff

Reply via email to