diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-19 21:10:28 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-19 21:10:28 +0000 |
commit | ef599b078676bcbfd462c28fa0e5078a6ae514b5 (patch) | |
tree | 548182921aa4d6eeca05acef15d1231129bfa0ec | |
parent | 3b93db72b44e72326fcd12b0a43261f866becaf6 (diff) | |
download | bcm5719-llvm-ef599b078676bcbfd462c28fa0e5078a6ae514b5.tar.gz bcm5719-llvm-ef599b078676bcbfd462c28fa0e5078a6ae514b5.zip |
Implement isMaxValueMinusOne in terms of APInt instead of uint64_t.
Patch by Sheng Zhou.
llvm-svn: 35188
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index e5207735931..1d44f6b9840 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -3449,14 +3449,13 @@ Instruction *InstCombiner::visitFRem(BinaryOperator &I) { // isMaxValueMinusOne - return true if this is Max-1 static bool isMaxValueMinusOne(const ConstantInt *C, bool isSigned) { + uint32_t TypeBits = C->getType()->getPrimitiveSizeInBits(); if (isSigned) { // Calculate 0111111111..11111 - unsigned TypeBits = C->getType()->getPrimitiveSizeInBits(); - int64_t Val = INT64_MAX; // All ones - Val >>= 64-TypeBits; // Shift out unwanted 1 bits... - return C->getSExtValue() == Val-1; + APInt Val(APInt::getSignedMaxValue(TypeBits)); + return C->getValue() == Val-1; } - return C->getZExtValue() == C->getType()->getBitMask()-1; + return C->getValue() == APInt::getAllOnesValue(TypeBits) - 1; } // isMinValuePlusOne - return true if this is Min+1 |