On Wed, May 23, 2012 at 11:16 AM, David Miller <davem@xxxxxxxxxxxxx> wrote: > > And believe it or not the "mask test each byte" thing is the fastest > portable code I could come up with. Big endian just blows for making > this calculation. It's not faster to just do something like int byte = 4; #if CONFIG_64BIT byte = 8; if (has_zero_32bit(value >> 32)) { value >>= 32; byte = 4; } #endif if (has_zero_16(value >> 16)) { value >>= 16; byte -= 2; } if (!value & 0xff00) byte--; return byte; which looks like it might generate ok code? > But hey Linus I'm willing to be proven wrong, why don't you ask your > google+ programming challenge entourage for some help? :-) Hey, I refuse to start from something that looks stupid. Btw, when benchmarking, make sure that your branches do not predict well. Because in real life they won't predict well. So you can't benchmark the mask->byte function with some well-behaved input that commonly returns the same value. > For reference here is the final version of the sparc commit, it works > and I've been running tests on it since last night. I'm extrmely > confident the C code will work on any big-endian machine. Umm. Except your "top of address space" thing is entirely sparc-specific. So no. The *bulk* of the code will work. But not all of it. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html