From: Jeff King Date: Sat, 03 Dec 2016 05:21:04 GMT Subject: Re: [PATCH 3/4] shallow.c: bit manipulation tweaks Message-ID: <20161203052104.jbxhzpweupiaz7wi@sigill.intra.peff.net> In-Reply-To: <1480710664-26290-3-git-send-email-rv@rasmusvillemoes.dk> 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