From: Duncan Sands Date: Wed, 26 Jan 2011 08:44:16 +0000 (+0000) Subject: APInt has a method for determining whether a number is a power of 2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=464a4f349c95a25d06d709e79d7df21fbbb155e2;p=oota-llvm.git APInt has a method for determining whether a number is a power of 2 which is more efficient than countPopulation - use it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124283 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 5320fa0768d..aa7769ea545 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -656,7 +656,7 @@ void llvm::ComputeSignBit(Value *V, bool &KnownZero, bool &KnownOne, /// types and vectors of integers. bool llvm::isPowerOfTwo(Value *V, const TargetData *TD, unsigned Depth) { if (ConstantInt *CI = dyn_cast(V)) - return CI->getValue().countPopulation() == 1; + return CI->getValue().isPowerOf2(); // TODO: Handle vector constants. // 1 << X is clearly a power of two if the one is not shifted off the end. If