This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/47914] New: __builtin_isunordered(Inf, NaN) doesn't work on linux-m68k/aranym


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

           Summary: __builtin_isunordered(Inf, NaN) doesn't work on
                    linux-m68k/aranym
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mikpe@it.uu.se


> cat compare-fp-1.c
/* derived from gcc.c-torture/execute/ieee/compare-fp-1.c */

float pinf;
float NaN;

void iun (void)
{
    float x = pinf;
    float y = NaN;

    if (!__builtin_isunordered (x, y))
        __builtin_abort();
}

int main (void)
{
    pinf = __builtin_inf ();
    NaN = __builtin_nan ("");
    iun ();
    return 0;
}
> gcc -O1 compare-fp-1.c ; ./a.out
Abort
> gcc -O1 -S compare-fp-1.c ; cat compare-fp-1.s
#NO_APP
        .file   "compare-fp-1.c"
        .text
        .align  2
        .globl  iun
        .type   iun, @function
iun:
        fmove.s pinf,%fp0
        fcmp.s NaN,%fp0
        fjun .L1
        jsr abort
.L1:
        rts
        .size   iun, .-iun
        .align  2
        .globl  main
        .type   main, @function
main:
        move.l #0x7f800000,pinf
        move.l #0x7fffffff,NaN
        jsr iun
        clr.l %d0
        rts
        .size   main, .-main
        .comm   NaN,4,2
        .comm   pinf,4,2
        .ident  "GCC: (GNU) 4.6.0 20110226 (experimental)"
        .section        .note.GNU-stack,"",@progbits

I'm not an expert on m68k FPU instructions, but this looks correct.  The bug
occurs with gcc-4.4/4.5/4.6 at all optimization levels.  In the gcc testsuite
it causes gcc.c-torture/execute/ieee/compare-fp-1.c to fail.  There are lots of
other FP test failures too, that may or may not be related to this one.

However, I'm running this on aranym (aranym-0.9.10-1.1.x86_64.rpm), so it's
possible that aranym is broken.  A gdb session seems to support that:

> gdb ./a.out
...
(gdb) break iun
Breakpoint 1 at 0x800003f8
(gdb) display/x $fpstatus
(gdb) display/i $pc
(gdb) run
Starting program: /home/mikpe/a.out 
(no debugging symbols found)
(no debugging symbols found)

Breakpoint 1, 0x800003f8 in iun ()
2: x/i $pc
0x800003f8 <iun>:       fmoves 0x80002670 <pinf>,%fp0
1: /x $fpstatus = 0x4000000
(gdb) stepi
0x80000400 in iun ()
2: x/i $pc
0x80000400 <iun+8>:     fcmps 0x80002674 <NaN>,%fp0
1: /x $fpstatus = 0x2000000
(gdb) 
0x80000408 in iun ()
2: x/i $pc
0x80000408 <iun+16>:    fbun 0x80000412 <iun+26>
1: /x $fpstatus = 0x2000000

*** Shouldn't fcmp on a NaN operand set the NAN bit (bit 24) of fpstatus?

(gdb) 
0x8000040c in iun ()
2: x/i $pc
0x8000040c <iun+20>:    jsr 0x8000030c <abort@plt>
1: /x $fpstatus = 0x0

Could someone please test this on a real m68k with an FPU?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]