Re: [PATCH] Make shr to divide by power of 2

From: Robert Hancock
Date: Fri Aug 07 2009 - 23:09:55 EST


On 08/07/2009 12:50 AM, Andi Kleen wrote:
Sergey Senozhatsky<sergey.senozhatsky@xxxxxxxxx> writes:
Of course, compiler supposed to do something like
add $0x7,%eax
shr $0x3,%eax
instead of div. Should we rely on this?

Yes. We should rely on this.

It may depend on the selected CPU type that gcc is optimizing for - I believe that on some P4s the shift may actually be slower than the divide..
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/