This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug inline-asm/15228] New: useless copies of floating point operands
- From: "sylvain dot pion at sophia dot inria dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Apr 2004 15:41:55 -0000
- Subject: [Bug inline-asm/15228] New: useless copies of floating point operands
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider the following function :
// Forces a double to memory
double force2memdouble(double x) {
asm("" : "=m"(x) : "m"(x));
return x;
}
This is used to force a double value in memory for platforms like x86
where the FP registers have too much precision.
It gets compiled by GCC (3.4 and 3.3.3, with -O2 -fomit-frame-pointer) to :
force2memdouble:
subl $12, %esp
fldl 16(%esp)
fstpl (%esp)
fldl (%esp)
addl $12, %esp
ret
I believe that the store/load is useless, and that the function could be
compiled as simply :
force2memdouble:
fldl 4(%esp)
ret
It is interesting to note that when using "int", "float" or "long double"
instead of "double", then there is no such useless store/load.
So, is this something that could be improved in GCC ?
Maybe the code responsible for asm() adds too many requirements
on the operands for doubles ?
--
Summary: useless copies of floating point operands
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: inline-asm
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sylvain dot pion at sophia dot inria dot fr
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15228