Implement isOneBitSet in terms of APInt::countPopulation.
authorReid Spencer <rspencer@reidspencer.com>
Mon, 19 Mar 2007 21:04:43 +0000 (21:04 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 19 Mar 2007 21:04:43 +0000 (21:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35186 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index e38622a569f4c2924135c6260ac3d1757da71de4..dbe694fad78e9de8b509192151d16980c6e09f1d 100644 (file)
@@ -3474,8 +3474,7 @@ static bool isMinValuePlusOne(const ConstantInt *C, bool isSigned) {
 // 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;
 }
 
 #if 0   // Currently unused