The difference being that the compiler knows what sort of bit-twiddling it should be doing and what sort of bit-twiddling it should not be doing.
I would not use this code without being very thoughtful and intentional about where it was being used.
> I would not use this code without being very thoughtful and intentional about where it was being used.
Sure, definitely not for everybody and every occasion. It's a platform dependent code. See my comment to cnvogel and look at his implementation for an example.
Actually it's not less useful than the code the compilers you depend on use all the time. They really depend on such "bit twiddles." Guy Steele agrees too, read his foreword to the "Hacker's Delight," a whole book about such functions:
http://www.hackersdelight.org/foreword.pdf