public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/41462]  New: redundant instructions with long double returned value
@ 2009-09-24 17:24 yuri at tsoft dot com
  2009-09-24 17:25 ` [Bug c/41462] " yuri at tsoft dot com
  2009-09-25  8:05 ` [Bug target/41462] " ubizjak at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: yuri at tsoft dot com @ 2009-09-24 17:24 UTC (permalink / raw)
  To: gcc-bugs

When I compile this function:
double f(long double i) {return (i);}
with gcc flags -S -O3, I get the assembly below.

There are two redundant FPU instructions there. double value is already in FPU
after fldt. No need to store it and load it back since difference between
double and long double is only in memory representation, and in FPU registers
they are the same.

---- asm output (relevant part) ----
f:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp   <---- redundant related stack adjustment
        fldt    8(%ebp)    
        fstpl   -8(%ebp)   <---- redundant STORE
        fldl    -8(%ebp)   <---- redundant LOAD
        leave
        ret


-- 
           Summary: redundant instructions with long double returned value
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: yuri at tsoft dot com


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


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

* [Bug c/41462] redundant instructions with long double returned value
  2009-09-24 17:24 [Bug c/41462] New: redundant instructions with long double returned value yuri at tsoft dot com
@ 2009-09-24 17:25 ` yuri at tsoft dot com
  2009-09-25  8:05 ` [Bug target/41462] " ubizjak at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: yuri at tsoft dot com @ 2009-09-24 17:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from yuri at tsoft dot com  2009-09-24 17:25 -------
Forgot to mention: 32-bit mode on i586 CPU.


-- 


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


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

* [Bug target/41462] redundant instructions with long double returned value
  2009-09-24 17:24 [Bug c/41462] New: redundant instructions with long double returned value yuri at tsoft dot com
  2009-09-24 17:25 ` [Bug c/41462] " yuri at tsoft dot com
@ 2009-09-25  8:05 ` ubizjak at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: ubizjak at gmail dot com @ 2009-09-25  8:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ubizjak at gmail dot com  2009-09-25 08:04 -------
(In reply to comment #0)

> There are two redundant FPU instructions there. double value is already in FPU
> after fldt. No need to store it and load it back since difference between
> double and long double is only in memory representation, and in FPU registers
> they are the same.

No, they are not. These instructions implement FP truncation from long-double
to double.  Try to compile your code with -ffast-math.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2009-09-25  8:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-24 17:24 [Bug c/41462] New: redundant instructions with long double returned value yuri at tsoft dot com
2009-09-24 17:25 ` [Bug c/41462] " yuri at tsoft dot com
2009-09-25  8:05 ` [Bug target/41462] " 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).