http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57974

--- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Paolo Carlini from comment #3)

> I suspect the back end could be also involved because it happens only for
> long double and I didn't see anything special for long double in builtins.c

-funsafe-math-optimizations are used here:

'-funsafe-math-optimizations'

     Allow optimizations for floating-point arithmetic that (a) assume
     that arguments and results are valid and (b) may violate IEEE or
     ANSI standards.  When used at link-time, it may include libraries
     or startup files that change the default FPU control word or other
     similar optimizations.

The __builtin_expl is expanded to:

        flds    .LC0(%rip)
        fld     %st(0)
        frndint
(*)     fsubr   %st, %st(1)
        fxch    %st(1)
        f2xm1
        fadds   .LC2(%rip)
        fscale
        fstp    %st(1)
        fstpt   16(%rsp)

and with fsubr, we hit Inf - Inf, which is by definition NaN.

Obviously, this testcase exposes the unsafe part of
-funsafe-math-optimizations. Without this option everything works OK.

Reply via email to