summaryrefslogtreecommitdiffstats
path: root/llvm/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
commitcc031a43aa7bbd617caf5dc6a19bc0b046182d5c (patch)
tree06257d62df083ac6cd33fa93befdbaf5da3e9e20 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp
parentb1ec2e8ec7e3e8779956a8eacab2f1782c249433 (diff)
downloadbcm5719-llvm-cc031a43aa7bbd617caf5dc6a19bc0b046182d5c.tar.gz
bcm5719-llvm-cc031a43aa7bbd617caf5dc6a19bc0b046182d5c.zip
APIntify the isHighOnes utility function.
llvm-svn: 35190
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 1d44f6b9840..c87a351e63b 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud