aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-03-19 21:08:07 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-03-19 21:08:07 +0000
commit727992c30aa8ddce0d935236cb57a4cb0de54d70 (patch)
tree705494052978fd80e96431ca58ff9fe0aca852be
parent44e33e674ad560b6e6d063a930e7af6d846fb0eb (diff)
downloadexternal_llvm-727992c30aa8ddce0d935236cb57a4cb0de54d70.zip
external_llvm-727992c30aa8ddce0d935236cb57a4cb0de54d70.tar.gz
external_llvm-727992c30aa8ddce0d935236cb57a4cb0de54d70.tar.bz2
Implement isMinValuePlusOne using facilities of APInt instead of uint64_t
Patch by Zhou Sheng. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35187 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index dbe694f..e520773 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -3463,12 +3463,11 @@ static bool isMaxValueMinusOne(const ConstantInt *C, bool isSigned) {
static bool isMinValuePlusOne(const ConstantInt *C, bool isSigned) {
if (isSigned) {
// Calculate 1111111111000000000000
- unsigned TypeBits = C->getType()->getPrimitiveSizeInBits();
- int64_t Val = -1; // All ones
- Val <<= TypeBits-1; // Shift over to the right spot
- return C->getSExtValue() == Val+1;
+ uint32_t TypeBits = C->getType()->getPrimitiveSizeInBits();
+ APInt Val(APInt::getSignedMinValue(TypeBits));
+ return C->getValue() == Val+1;
}
- return C->getZExtValue() == 1; // unsigned
+ return C->getValue() == 1; // unsigned
}
// isOneBitSet - Return true if there is exactly one bit set in the specified