On 08/29/2012 05:46 PM, Oleg Endo wrote:
Hello,
While experimenting a little bit with an idea for an address mode
selection RTL pass for SH, I realized that SH's sh_address_cost function
is quite broken. When trying to fix it, I ran against a wall, since the
mode of the MEM is not passed to the target hook function, as it is e.g.
in legitimate_address. This circumstance makes it a bit difficult to
return useful answers in the address_cost hook. Like on SH,
displacement address modes for anything < SImode are considered slightly
more expensive due to increased pressure on R0.
Since everything in the middle-end already seems to pass the mode to the
'address_cost' function in rtlanal.c, I'd like to propose to forward the
mode arg to the target hook. The change is quite obvious, as it only
adds one new (mostly) unused argument to the various address_cost
functions in the targets.
I went through all the targets' code and fixed the hook function. It
seems some other targets than SH could also benefit from the mode wisdom
in their address_cost estimation.
There are a few peculiarities I ran across (respective target
maintainers CC'ed):
microblaze:
The microblaze_address_cost takes the mode of the address rtx.
Maybe it is meant to take the mode of the MEM?
The address cost calculation looks OK. I'm not sure why the mode of
MEM is relevant to this computation.
No objections to the patch.
--
Michael Eager ea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077