On 03/25/2010 11:24 PM, Steven Bosscher wrote:
On Thu, Mar 25, 2010 at 4:03 PM, Jie Zhang<j...@codesourcery.com>  wrote:
I just found that the current RTL code hoisting cannot optimize

REG = ...
if (cond)
  {
    r0 = REG;
    ....
  }
else
  {
    r0 = REG;
    ...
  }

to


REG = ...
r0 = REG;
if (cond)
  {
    ....
  }
else
  {
    ...
  }

where REG is a pseudo register and r0 is a physical register. I have looked
at the code of RTL hoisting pass. But I cannot find a simple way to extend
it to deal with this case.

Right, there are two issues:
* HOIST doesn't handle hard registers
* HOIST doesn't hoist reg-reg moves

There is no easy way to add cost metrics to hoist reg-reg moves, and
handling hard regs is an even bigger problem.

What is the original code? I (well, by now: we) have patches in the
works for GCC 4.6 that add code hoisting to GIMPLE (see PR23286),
perhaps that solves this case for you.

I'm not sure if I can make the test case public. I need to ask. I'm afraid gimple cannot help this. r0 is here because it's used for passing argument to callees. This issue is only exposed when expanded to RTL.


And the hoisting pass is only enabled when -Os.
So I'm going to implement another hoisting pass to do this optimization. Is
it a good idea?

To add duplicate functionality? No.

I'm not going to add duplicate functionality. What I'm going to do is only handle "hard-reg = pseudo-reg" case.

Does anyone know if there is an existing pass which should
have handled or be able to be easily adapted to handle this case?

Hoisting should handle it, bui


Can you open a new PR and make it block PR33828, please?

If I can publish the test case, yes. Or I have to rewrite a test case.


--
Jie Zhang
CodeSourcery
(650) 331-3385 x735

Reply via email to