RFC: using clz for comparing to zero on the tree level.

Olly Betts olly@survex.com
Fri May 9 02:12:00 GMT 2003


Richard Henderson wrote:
> On Thu, May 08, 2003 at 12:36:35PM -0400, David Edelsohn wrote:
>> 	Not Alpha and not ARM V5, which have single instruction clz?
> 
> [...]
> 
> ARM:
> 	cmp	in, #0
> 	movne	out, #0
> 	moveq	out, #1
> 
> Hmm, so it might be a win for ARM.  You'll have to work out
> with Richard Earnshaw how you want to arrange these costs.
> At the moment arm_rtx_costs doesn't tell you that the SEQ
> operation takes 3 instructions.

This isn't directly relevant to the clz issue, but I notice that the
above sequence isn't optimal for any ARM - this is better:

	rsbs	out, in, #1
	movcc	out, #0

This is essentially: out = 1 - in; if ((unsigned)in > 1) out = 0;

Cheers,
    Olly



More information about the Gcc mailing list