This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/66462] New: GCC isinf/isnan/... builtins cause sNaN exceptions
- From: "wdijkstr at arm dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 08 Jun 2015 14:20:37 +0000
- Subject: [Bug middle-end/66462] New: GCC isinf/isnan/... builtins cause sNaN exceptions
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66462
Bug ID: 66462
Summary: GCC isinf/isnan/... builtins cause sNaN exceptions
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: wdijkstr at arm dot com
Target Milestone: ---
The isinf, isnan, isnormal, isfinite, fpclassify and signbit builtins use FP
arithmetic to compute their result even with -fsignaling-nans (signbit only
when -ffast-math is also used). This means sNaNs cause invalid operation
exceptions which is incorrect according to the IEEE754-2008 standard.
The reason is the use of FP comparisons. Integer arithmetic avoids this, and is
typically faster, especially when using softfloat.
int snan_fail(double x)
{
return __builtin_isinf (x);
}
gcc6.0 -O2 -fsignaling-nans generates for AArch64:
snan_fail:
ldr d1, .LC7
fabs d0, d0
fcmp d0, d1 // will signal on sNaN...
cset w0, gt
ret