On 03/25/10 10:19, Jie Zhang wrote:
On 03/25/2010 11:22 PM, Jeff Law wrote:
I never bothered to implement hoisting which touched hard regs -- I
never thought the cost/benefit analysis made much sense. It's quite a
bit more work to implement and code motion of hard regs is much more
restricted than code motion involving just pseudos.
Thanks Bernd and Jeff.
This case is not common. I'm wondering how likely this kind of
optimization pass will be accepted into GCC.
If the code is clean and doesn't add significant compile-time overhead,
it'd probably be accepted.
Another way to fix it is teaching register allocator to allocate r0 to
REG. But I guess it's more difficult.
Well, the register allocator will already attempt to allocate REG to r0
-- when it sees a copy between a pseudo and a hard reg it will adjust
its cost model appropriately to encourage the pseudo to be allocated to
the hard reg (thus eliminating the copy).
It's probably at least worth looking into why the pseudos in question
aren't being assigned to the appropriate hard register to eliminate the
copy.
Another alternative would be to look at something like copy motion (see
Morgan's text). I've always wondered if it was generally useful and
what it's compile-time impact might be.
Jeff