Operator overloading in (MIPS) assembly-language

Jim Wilson wilson@specifixinc.com
Tue Mar 30 09:46:00 GMT 2004


Barry Wealand wrote:
> We've been working with a GNU MIPS cross-compiler / toolset, generating
> code for MIPS-like hardware to which we've added some new features.

You didn't mention the gcc version.  I get worse results with current 
gcc sources.

> (I've added the line numbers for convenience).  Everything in this
> listing looks perfectly normal except lines 25 through 30.  None of
> these 6 store instructions serves any purpose at all.

Probably new_float is a type that can't be allocated to a floating point 
register, so it gets allocated to a stack slot.  We then generate code 
that includes reads and writes from/to these stack slots.  The reads are 
fairly easy to optimize away, but the writes are a different problem. 
This requires complicated alias analysis support which we don't have, so 
the writes remain.  The writes are all to the same stack slot because 
all of the "new_float f" in all of the inlined method calls got assigned 
to the same stack slot.  In this particular case, it isn't hard to see 
that the stores are all redundant and could be optimized away, but the 
general case is very complicated, and difficult to implement.

In current sources, I get worse code, probably because the ABI has 
changed such that new_float as a argument is no longer passed in 
floating point registers, thus requiring a lot of loads to access the A, 
B, and C values.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



More information about the Gcc mailing list