This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/16815] New: MIPS n32/n64 inefficient code for float arguments
- From: "wilson at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Jul 2004 02:05:21 -0000
- Subject: [Bug middle-end/16815] New: MIPS n32/n64 inefficient code for float arguments
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
If you compile code using a float argument, and compile with optimization for
the n32 or n64 ABIs, then gcc-3.4 and later will emit code that stores the float
arg onto the stack, and then loads it back into a register.
A trivial example
float
sub (float f, float g)
{
return f + g;
}
gives
swc1 $f12,0($sp)
swc1 $f13,16($sp)
lwc1 $f1,16($sp)
lwc1 $f0,0($sp)
add.s $f0,$f0,$f1
The problem here is related to the definition of the BLOCK_REG_PADDING macro in
the mips port. A float arg has natural alignment in a register, but when
big-endian, it has the "wrong" alignment in a stack slot. In this case,
FUNCTION_ARG_PADDING and BLOCK_REG_PADDING return different values. There is
code in function.c in assign_parms_setup_block_p that forces values onto the
stack if they have the wrong padding, but there are a number of things wrong
here. It is testing locate->where_pad, but this is from FUNCTION_ARG_PADDING,
not BLOCK_REG_PADDING. If the argument was passed in a reg, then
FUNCTION_ARG_PADDING should be irrelevant here. It should be testing
BLOCK_REG_PADDING instead, and possibly only if the arg was passed in a
register. Also, there is the issue of why we are storing it to the stack,
instead of just shifting it into position as is done in calls.c. I am unsure
what the purpose of this code is, so I am unsure what exact fix is needed here.
I haven't tried to fully analyze the code yet.
I am mainly filing this to document the problem, so I won't forget it. I
noticed it while doing other work.
I don't care whether this gets fixed in gcc-3.4.
--
Summary: MIPS n32/n64 inefficient code for float arguments
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wilson at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: mips64-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16815