On Sat, Jan 09, 2010 at 02:41:02PM -0800, Philip Guenther wrote: > >> I find your lack of faith in the compiler disturbing. > > > > I find your lack of type checking before trolling disturbing. > > <stares at the code> > > Ummm, what? > > AFAICT, the only difference between the two variants that I can see is > that the shift version might behave differently if numvnodes is > negative, which can't happen. Can you be less funny and more clear > about what type checking issue you see?
You have analysed the situation correctly. The problem is that the compiler does not know that the signed numvnodes is never negative, so it creates different code. E.g. on AMD64 it is 6 instructions for the signed division by 2 compared to one instruction for the explicit shift or the unsigned division. Joerg