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 | 3a2a9fbf997e42cb05c0d1f07b7445aa804ca711 (patch) | |
tree | 1a9eeabc66cdb9f0a98db4179dc86993d7099bdf | |
parent | 727992c30aa8ddce0d935236cb57a4cb0de54d70 (diff) |
Implement isMaxValueMinusOne in terms of APInt instead of uint64_t.
Patch by Sheng Zhou.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35188 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index e520773593..1d44f6b984 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/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 |