public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/49257] New: -mfpmath=sse generates x87 instructions on 32 bits OS
@ 2011-06-01 13:57 olivier_maury at mentor dot com
  2011-06-01 14:25 ` [Bug target/49257] " rguenth at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: olivier_maury at mentor dot com @ 2011-06-01 13:57 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: -mfpmath=sse generates x87 instructions on 32 bits OS
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: olivier_maury@mentor.com


Created attachment 24408
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24408
simple reproducer

Hi,

Please find attached a simple C program that shows the issue.
I compile it that way:

gcc -O0 simple.c -mfpmath=sse -msse3 -o ok.exe
./ok.exe returns the correct value

gcc -O0 simple.c -mfpmath=sse -msse3 -DRETURN_NAN -o nan.exe
./nan.exe returns a NAN

Both exe use some gcc intrinsic that change the FP stack into mmx registers. It
is expected that if I call a libc function (like printf) without restoring the
stack to its original state (using emms) then I'll have a wrong behavior. But,
here, because of the following assembly code:
.L4:
        fildq   72(%esp)
        cmpl    $0, 76(%esp)
        jns     .L3
        fldt    .LC2
        faddp   %st, %st(1)
.L3:
        fstpl   24(%esp)
        movsd   24(%esp), %xmm0
        mulsd   56(%esp), %xmm0
        movsd   %xmm0, 40(%esp)
        movl    68(%esp), %eax
        movl    4(%eax), %edx
        movl    (%eax), %eax
        movl    52(%esp), %ecx
        movl    %eax, 16(%esp)
        movl    %edx, 20(%esp)
        movq    16(%esp), %mm0
        movntq  %mm0, (%ecx)
        addl    $1, 72(%esp)
        adcl    $0, 76(%esp)
.L2:
        cmpl    $0, 76(%esp)
        jb      .L4
        cmpl    $0, 76(%esp)
        ja      .L6
        cmpl    $9, 72(%esp)
        jbe     .L4


I've got a NAN why I shouldn't !?

The instruction that generates that x87 code is the line
(double)i * coeff; where i is an unsigned long long and coeff is a double. 
It works well if for instance 'i' is a long/int/unsigned int.

Maybe that behavior is expected ?

BR

Olivier


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

end of thread, other threads:[~2012-01-20 11:08 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-01 13:57 [Bug c/49257] New: -mfpmath=sse generates x87 instructions on 32 bits OS olivier_maury at mentor dot com
2011-06-01 14:25 ` [Bug target/49257] " rguenth at gcc dot gnu.org
2011-06-01 17:58 ` ubizjak at gmail dot com
2011-06-01 18:28 ` ubizjak at gmail dot com
2011-06-01 20:53 ` ubizjak at gmail dot com
2011-06-01 20:55 ` ubizjak at gmail dot com
2011-06-06  8:44 ` rguenth at gcc dot gnu.org
2011-06-06 15:49 ` rth at gcc dot gnu.org
2011-06-06 18:34 ` ubizjak at gmail dot com
2011-06-06 19:02 ` rth at gcc dot gnu.org
2011-06-06 21:08 ` ubizjak at gmail dot com
2011-06-07  8:39 ` ubizjak at gmail dot com
2011-06-07 13:18 ` ubizjak at gmail dot com
2011-06-07 18:41 ` rth at gcc dot gnu.org
2011-06-07 23:13 ` rth at gcc dot gnu.org
2011-06-08  6:14 ` jakub at gcc dot gnu.org
2011-06-08 10:32 ` ubizjak at gmail dot com
2011-06-09 15:41 ` rth at gcc dot gnu.org
2012-01-20 11:31 ` ubizjak at gmail 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).