public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/66462] New: GCC isinf/isnan/... builtins cause sNaN exceptions
@ 2015-06-08 14:20 wdijkstr at arm dot com
  2015-06-08 14:57 ` [Bug middle-end/66462] " wdijkstr at arm dot com
  0 siblings, 1 reply; 2+ messages in thread
From: wdijkstr at arm dot com @ 2015-06-08 14:20 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug middle-end/66462] GCC isinf/isnan/... builtins cause sNaN exceptions
  2015-06-08 14:20 [Bug middle-end/66462] New: GCC isinf/isnan/... builtins cause sNaN exceptions wdijkstr at arm dot com
@ 2015-06-08 14:57 ` wdijkstr at arm dot com
  0 siblings, 0 replies; 2+ messages in thread
From: wdijkstr at arm dot com @ 2015-06-08 14:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66462

--- Comment #1 from Wilco <wdijkstr at arm dot com> ---
Note when this is fixed, GLIBC math/math.h should be updated to enable the
isinf builtins even with -fsignaling-nans.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-08 14:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-08 14:20 [Bug middle-end/66462] New: GCC isinf/isnan/... builtins cause sNaN exceptions wdijkstr at arm dot com
2015-06-08 14:57 ` [Bug middle-end/66462] " wdijkstr at arm dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).