diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-19 21:08:07 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-19 21:08:07 +0000 |
commit | 3b93db72b44e72326fcd12b0a43261f866becaf6 (patch) | |
tree | e632890bd90dce536af3aedf4b058f0efaf0c75d /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | 129a86792d1a356d0da7ccea7c4262448c1d37ea (diff) | |
download | bcm5719-llvm-3b93db72b44e72326fcd12b0a43261f866becaf6.tar.gz bcm5719-llvm-3b93db72b44e72326fcd12b0a43261f866becaf6.zip |
Implement isMinValuePlusOne using facilities of APInt instead of uint64_t
Patch by Zhou Sheng.
llvm-svn: 35187
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-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 dbe694fad78..e5207735931 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/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 |