On Fri, Dec 02, 2016 at 09:31:03PM +0100, Rasmus Villemoes wrote:
First of all, 1 << 31 is technically undefined behaviour, so let's just
use an unsigned literal.
It took me a second to realize that you weren't talking about the
unsigned parameter here. You mean using "1U". It might be worth saying:
...use an unsigned literal, "1U".
to make it more obvious.
If i is 'signed int' and gcc doesn't know that i is positive, gcc
generates code to compute the C99-mandated values of "i / 32" and "i %
32", which is a lot more complicated than simple a simple shifts/mask.
Right, that makes sense (though it is a separate issue).
-Peff