On Thu, Feb 12, 2026 at 5:05 AM Andrew Pinski <[email protected]> wrote: > > This was an oversight on my part (after r16-6435-g594f2cbf30f0a3) > where I forgot that sometimes reversed_comparison_code will return > UNKNOWN when the floating point comparison can't be reversed. > This seems only to show up with RTL checking only; at least as far > as I can tell because it is rejected later on but I could be wrong. > > Bootstrapped and tested on x86_64-linux-gnu.
OK. > PR rtl-optimization/124062 > > gcc/ChangeLog: > > * ifcvt.cc (noce_try_cond_arith): Check the conditional code > for UNKNOWN. > > gcc/testsuite/ChangeLog: > > * gcc.dg/torture/pr124062-1.c: New test. > > Signed-off-by: Andrew Pinski <[email protected]> > --- > gcc/ifcvt.cc | 3 +++ > gcc/testsuite/gcc.dg/torture/pr124062-1.c | 14 ++++++++++++++ > 2 files changed, 17 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/torture/pr124062-1.c > > diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc > index ca996d6ae19..7f5af2ca915 100644 > --- a/gcc/ifcvt.cc > +++ b/gcc/ifcvt.cc > @@ -3194,6 +3194,9 @@ noce_try_cond_arith (struct noce_if_info *if_info) > else if (!(noce_cond_zero_binary_op_supported (a) && REG_P (b))) > goto fail; > > + if (code == UNKNOWN) > + goto fail; > + > op = GET_CODE (a); > > /* Canonicalize x = (z op y) : y to x = (y op z) : y */ > diff --git a/gcc/testsuite/gcc.dg/torture/pr124062-1.c > b/gcc/testsuite/gcc.dg/torture/pr124062-1.c > new file mode 100644 > index 00000000000..d59064c5d4d > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/torture/pr124062-1.c > @@ -0,0 +1,14 @@ > +/* { dg-do compile } */ > + > +/* PR rtl-optimization/124062 */ > + > +void a(int); > +double b; > +void c(int d, int e) { > + int f = e; > + if (b < 0) > + f += d; > + a(f); > + a(e); > +} > + > -- > 2.43.0 >
