On Wed, 22 Jul 2026 at 14:59, Kyrylo Tkachov <[email protected]> wrote:
>
>
>
> > On 22 Jul 2026, at 08:50, Philipp Tomsich <[email protected]> wrote:
> >
> > noce_emit_store_flag feeds the possibly-reversed comparison code to a
> > store-flag insn, and to emit_store_flag, without checking that the
> > reversal succeeded. reversed_comparison_code returns UNKNOWN for
> > UNLT/UNLE/UNGT/UNGE, and for a MODE_CC comparison it cannot trace back
> > to its COMPARE -- common for a floating-point condition on targets that
> > compare into a condition-code register. emit_store_flag then reaches
> > its floating-point path and calls swap_condition (UNKNOWN), which aborts.
> >
> > This was latent until r17-2519-ga33f26607eb4f3
> > (noce_try_shifted_store_flag),
> > the first caller to reach noce_emit_store_flag with REVERSEP set for such
> > a condition.
> >
> > Bail out early when the reversal failed.
> >
> > Bootstrapped and regression tested on aarch64-unknown-linux-gnu with no
> > regressions.
> >
> > PR rtl-optimization/126347
> > gcc/
> > * ifcvt.cc (noce_emit_store_flag): Return NULL_RTX when the
> > comparison code is UNKNOWN.
>
> LGTM (though I’m not a maintainer) but could you add a creduced/cvised test
> case from the ICE in the PR?
Hi Kyrill,
Thanks for taking a look!
I gave the reduction a try and it didn't lead anywhere: The ICE needs
the specific whole-program LTO inlining+partitioning of the full
753.ns3_r link.
A single TU doesn't reproduce even at -flto, and relinking the exact
same object set (with a compiler that has r17-2519-ga33f26607eb)
already fails to reproduce, because the partitioning shifts
So neither a single-file creduce nor a reduced gcc.dg/lto/ case
converges, and cvise's only stable reproducer is the multi-minute
full-benchmark build.
I can instead try for an __RTL test that feeds the ce2 pass the exact
pattern (target-specific, but reproducible)?
Otherwise I'd propose going in without a dg testcase given the
whole-program nature...
Thanks,
Philipp.
> Thanks,
> Kyrill
>
> > ---
> > gcc/ifcvt.cc | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc
> > index 7c50ab06e2f7..6b169e69741d 100644
> > --- a/gcc/ifcvt.cc
> > +++ b/gcc/ifcvt.cc
> > @@ -865,6 +865,11 @@ noce_emit_store_flag (struct noce_if_info *if_info,
> > rtx x, bool reversep,
> > else
> > code = GET_CODE (cond);
> >
> > + /* reversed_comparison_code returns UNKNOWN for an unordered code, or a
> > + CC-mode compare it cannot trace; neither path below can use that. */
> > + if (code == UNKNOWN)
> > + return NULL_RTX;
> > +
> > if ((if_info->cond_earliest == if_info->jump || cond_complex)
> > && (normalize == 0 || STORE_FLAG_VALUE == normalize))
> > {
> > --
> > 2.34.1
> >
>