Jeff Law <l...@redhat.com> writes:

> On 5/8/19 6:20 AM, Richard Biener wrote:
>> On Wed, 8 May 2019, Jiufu Guo wrote:
>> 
>> The main thing the transform does is tail-duplicate the PHI block,
>> if we'd just do that followup transforms would do the rest.
> One might even claim this is really a transformation for cfg cleanups.
> If we ignore the PHI what we have is a unconditional jump to a
> conditional jump.  The obvious way to optimize that is to replace the
> unconditional jump with a copy of the conditional jump.
>

>> Btw, I wonder if on RTL basic-block reordering (which also does
>> some tail duplication) could be a place to do such transform?
>> Or is it too late to do the desired cleanups after that?
>> Possibly since we're after RA.IIRC we've had code in jump.c to do this in 
>> the past.  It may have
> morphed through the years, but I'm pretty sure we've done this kind of
> thing on a low level before.

Yes, RTL basic-block reordering duplicate the conditional jump and
replace unconditional jump with it:
   17: %9:DI=%9:DI^0x1
   19: %9:DI=zero_extend(%9:QI)
   58: pc=L31
   59: barrier
--->
   17: %9:DI=%9:DI^0x1
   19: %9:DI=zero_extend(%9:QI)
   33: %0:CC=cmp(%9:DI,0)
      REG_DEAD %9:DI
   34: pc={(%0:CC!=0)?L90:pc}
      REG_DEAD %0:CC
      REG_BR_PROB 354334804

While, the conditional jump is still using GPR even the GPR(%9:DI) is
result of a CMP instruction. Because moving CMP result to GPR is
generated when tranforming gimple to rtl. 

To elimiate the instructions which moving result of CMP to GPR, I'm
wondering maybe we could do a combine(or a peephole) after bbro to let
the condition jump directly using the result of CMP.

Jiufu Guo.

> jeff

Reply via email to