On 9/20/26 11:25 AM, Matt Turner wrote:
GCC expands __builtin_isnan, __builtin_isinf, __builtin_isfinite and
__builtin_isnormal into FP comparisons on alpha, and by default those
comparisons carry no software-completion suffix:
isnan_d:
cmptun $f16,$f16,$f10
fbne $f10,$L11
A subnormal operand raises a denormal-operand exception there, and the
outcome depends on the FPCR denormal-operand-disable bit: the operand is
flushed to zero, which makes a subnormal indistinguishable from a zero,
or the trap is delivered with no completion information, which is fatal:
$ cat cls.c
#include <math.h>
int main (void)
{
volatile double sub = 0x1p-1050;
return fpclassify (sub);
}
$ ./cls
Floating point exception (core dumped)
-mieee is the documented way to get subnormal support, so this is a
matter of quality of implementation rather than conformance, but the
classification built-ins exist to detect exactly these values and should
not kill the process when given one. Classify by inspecting the encoding
in an integer register instead, as the AArch64 isinf, isfinite and isnan
expanders do for PR66462. Defining these patterns also stops
fold_builtin_interclass_mathfn from rewriting the built-ins into
comparisons in the first place.
With -mieee the comparisons are completed by the kernel and are cheaper,
so keep the generic expansions there, except with -fsignaling-nans: a
comparison raises an invalid-operation exception for a signaling NaN,
which is the PR66462 case that AArch64 and LoongArch handle the same way.
gcc/ChangeLog:
PR middle-end/66462
* config/alpha/alpha-protos.h (enum alpha_fp_class): New.
(alpha_expand_fp_classify): Declare.
* config/alpha/alpha.cc (alpha_expand_fp_classify): New function.
* config/alpha/alpha.md (isfinite<mode>2, isinf<mode>2)
(isnan<mode>2, isnormal<mode>2): New expanders.
gcc/testsuite/ChangeLog:
PR middle-end/66462
* gcc.target/alpha/fp-classify-1.c: New test.
* gcc.target/alpha/fp-classify-2.c: New test.
* gcc.target/alpha/fp-classify-3.c: New test.
* gcc.target/alpha/fp-classify-4.c: New test.
Thanks. I've pushed this series to the trunk.
jeff