Re: do_div vs sector_t

Russell King (rmk@arm.linux.org.uk)
Sun, 13 Jul 2003 18:39:37 +0100


On Sun, Jul 13, 2003 at 10:26:23AM -0700, Richard Henderson wrote:
> On Fri, Jul 11, 2003 at 11:33:59PM +0100, Matthew Wilcox wrote:
> > Better ideas?
>
> if (likely(((n) >> 31 >> 1) == 0)) {
>

Beware - luckily I don't have to worry about that on ARM (we do our own
thing.) However, with this code:

int foo(unsigned long long n)
{
if (((n) >> 31 >> 1) == 0) {
return 1;
} else {
return 0;
}
}

gcc 3.2.2 on ARM (32-bit) produces some not-very-nice code, consisting of
6 shifts and including placing one register on the stack and completely
ignoring a register which it could freely use instead.

-- 
Russell King (rmk@arm.linux.org.uk)                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/