[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
clattner at apple.com
Mon Mar 19 14:16:47 PDT 2007
> Implement isOneBitSet in terms of APInt::countPopulation.
> @@ -3474,8 +3474,7 @@
> // isOneBitSet - Return true if there is exactly one bit set in
> the specified
> // constant.
> static bool isOneBitSet(const ConstantInt *CI) {
> - uint64_t V = CI->getZExtValue();
> - return V && (V & (V-1)) == 0;
> + return CI->getValue().countPopulation() == 1;
> }
Are you sure this is a good idea? countPopulation is *much* slower
than a couple of and's and a subtract.
-Chris
More information about the llvm-commits
mailing list