public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/55952] New: x86 FPU, unnecessary fxch instruction
@ 2013-01-11 22:46 vhaisman at gmail dot com
2013-01-13 11:28 ` [Bug rtl-optimization/55952] " ubizjak at gmail dot com
0 siblings, 1 reply; 2+ messages in thread
From: vhaisman at gmail dot com @ 2013-01-11 22:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55952
Bug #: 55952
Summary: x86 FPU, unnecessary fxch instruction
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: vhaisman@gmail.com
I am wondering if there are not some improvements that could be made in
generation of x86 FPU code. Here is a simple sign function:
float signf4(float x)
{
return x < 0.0f
? -1.0f
: 1.0f;
}
It generates the following assembler code (GCC 4.7.2, g++ -m32 -O3
-fverbose-asm -save-temps -g3 -ggdb -march=native):
_Z6signf4f:
.LFB84:
.loc 1 27 0
.cfi_startproc
.LVL4:
.loc 1 30 0
fld1
fldz
flds 4(%esp) # x
fxch %st(1) # ??? Why?
fucomip %st(1), %st #,
ffreep %st(0) #
fld1
fchs
fcmovbe %st(1), %st #,,
fstp %st(1) #
.loc 1 31 0
ret
I am wondering why is the fxch instruction necessary and why is the code
not instead like this?
_Z6signf4f:
.LFB84:
.loc 1 27 0
.cfi_startproc
.LVL4:
.loc 1 30 0
fld1
flds 4(%esp) # ??? Load the parameter before the zero.
fldz # ??? to avoid the fxch instruction.
fucomip %st(1), %st #,
[...]
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug rtl-optimization/55952] x86 FPU, unnecessary fxch instruction
2013-01-11 22:46 [Bug rtl-optimization/55952] New: x86 FPU, unnecessary fxch instruction vhaisman at gmail dot com
@ 2013-01-13 11:28 ` ubizjak at gmail dot com
0 siblings, 0 replies; 2+ messages in thread
From: ubizjak at gmail dot com @ 2013-01-13 11:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55952
Uros Bizjak <ubizjak at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
--- Comment #1 from Uros Bizjak <ubizjak at gmail dot com> 2013-01-13 11:28:23 UTC ---
Duplicate of PR15492.
*** This bug has been marked as a duplicate of bug 15492 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-13 11:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-11 22:46 [Bug rtl-optimization/55952] New: x86 FPU, unnecessary fxch instruction vhaisman at gmail dot com
2013-01-13 11:28 ` [Bug rtl-optimization/55952] " 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).