aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-03-19 21:29:50 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-03-19 21:29:50 +0000
commit05227d88aff1223cdaa28ff401a3c88b36d285eb (patch)
tree5176d57e9e33fdd793c4415cd22d88c616d713af /lib/Transforms/Scalar/InstructionCombining.cpp
parentadf2a206ecc11cc6427cc0aa19d366089c8b747f (diff)
APIntify the isHighOnes utility function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35190 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 1d44f6b984..c87a351e63 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -3491,14 +3491,15 @@ static bool isLowOnes(const ConstantInt *CI) {
// isHighOnes - Return true if the constant is of the form 1+0+.
// This is the same as lowones(~X).
static bool isHighOnes(const ConstantInt *CI) {
- uint64_t V = ~CI->getZExtValue();
- if (~V == 0) return false; // 0's does not match "1+"
+ if (CI->getValue() == 0) return false; // 0's does not match "1+"
+
+ APInt V(~CI->getValue());
// There won't be bits set in parts that the type doesn't contain.
- V &= ConstantInt::getAllOnesValue(CI->getType())->getZExtValue();
+ V &= APInt::getAllOnesValue(CI->getType()->getBitWidth());
- uint64_t U = V+1; // If it is low ones, this should be a power of two.
- return U && V && (U & V) == 0;
+ APInt U(V+1); // If it is low ones, this should be a power of two.
+ return (U!=0) && (V!=0) && (U & V) == 0;
}
/// getICmpCode - Encode a icmp predicate into a three bit mask. These bits