]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Add isnan expander [PR 66462]
authorXi Ruoyao <xry111@xry111.site>
Tue, 16 Sep 2025 15:10:26 +0000 (23:10 +0800)
committerXi Ruoyao <xry111@xry111.site>
Wed, 24 Sep 2025 08:24:41 +0000 (16:24 +0800)
commit2c98d7cf3a151e3d464a8e4a161d084494281d76
tree947b04482d8629990ddf2698cbb1b8d742f77185
parentfe2f86a960435a7c8c4e5134a0dfc64dd6062157
LoongArch: Add isnan expander [PR 66462]

Add an expander for isnan using fclass.  Since isnan is
just a compare, enable it only with -fsignaling-nans to avoid
generating spurious exceptions.  This fixes part of PR66462.

int isnan1 (float x) { return __builtin_isnan (x); }

With -fno-signaling-nans:

fcmp.cun.s $fcc0,$f0,$f0
movcf2fr $f0,$fcc0
movfr2gr.s $r4,$f0
jr $r1

With -fsignaling-nans:

fclass.s $f0,$f0
movfr2gr.s $r4,$f0
andi $r4,$r4,3
sltu $r4,$r0,$r4
jr $r1

PR middle-end/66462

gcc/

* config/loongarch/loongarch.md (FCLASS_MASK): Add 3.
(fclass_optab): Assign isnan for 3.
(<FCLASS_MASK:fclass_optab><ANYF:mode>2): If FCLASS_MASK is 3,
only enable when -fsignaling-nans.

gcc/testsuite:

* gcc.target/loongarch/fclass-compile.c: Update test.
* gcc.target/loongarch/fclass-run.c: Likewise.
gcc/config/loongarch/loongarch.md
gcc/testsuite/gcc.target/loongarch/fclass-compile.c
gcc/testsuite/gcc.target/loongarch/fclass-run.c