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

--- Comment #4 from Mohamed <mohamed.selim at dxc dot com> ---
gcc-12 aarch64 outputs:

        .arch armv8-a
        .file   "main.cpp"
        .text
        .align  2
        .p2align 4,,11
        .global test::is_std_nan(float)
        .type   test::is_std_nan(float), %function
test::is_std_nan(float):
.LFB2710:
        fcmp    s0, s0
        cset    w0, vs
        ret
.LFE2710:
        .size   test::is_std_nan(float), .-test::is_std_nan(float)
        .align  2
        .p2align 4,,11
        .global test::is_std_nan(double)
        .type   test::is_std_nan(double), %function
test::is_std_nan(double):
.LFB2711:
        fcmp    d0, d0
        cset    w0, vs
        ret
.LFE2711:

One thing that was noticed also in gcc-12 generated assembly(above) built on
arm-v8, that the binary generated is triggering FE_INVALID, but due to
something else.
I believe it boils down to the fact that compare inst "fcmp     d0, d0" or
"fcmp        s0, s0" which when it compares nan with nan it ends up triggering
FE_INVALID.


Yet, also with clang using the flag "-ffp-exception-behavior=strict", generates
on arm-v8

test::is_std_nan(double):                 // @test::is_std_nan(double)
// %bb.0:
        fmov    x9, d0
        mov     x8, #9218868437227405312        // =0x7ff0000000000000
        and     x9, x9, #0x7fffffffffffffff
        cmp     x9, x8
        cset    w0, gt
        ret 
Which doesn't trigger FE_INVALID.

Reply via email to