BCT optimization

David Edelsohn dje@watson.ibm.com
Thu Oct 1 03:23:00 GMT 1998


>>>>> Jeffrey A Law writes:

Jeff> I don't see the need to emit special patterns either.  Make it look like
Jeff> canonical rtl.
Jeff> ie, initialize a pseudo before the loop in the normal way to hold the loop
Jeff> counter.  Then at the end of the loop emit a pattern which decrements the
Jeff> pseudo and conditionally branches back to the start of the loop.

Jeff> In addition to being much cleaner, it would allow targets where the count
Jeff> register is actually a general register to use this optimization (and yes,
Jeff> such targets exist).

	On PowerPC, secondary reload already knows that it needs a GPR to
load the CTR register.

	The decrement_and_branch_on_count patterns already can handle any
register, not just CTR, in case the CTR was not available.  This is
because they are based on the original decrement_and_branch_until_zero
patterns.  I don't think that Michael's patterns are that flexible yet.

	A problem with assigning a pseudo and allowing reload to choose
the register is that this optimization is specifically scheduling the use
of this resource based on additional criteria about when it is
beneficial.  I am a little concerned about not stuffing in the count or
loop register early if reload thinks it is smarter and wants to override
the cost-benefit decision about that resource.

David



More information about the Gcc mailing list