summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKay Tiong Khoo <kkhoo@perfwizard.com>2013-12-02 22:20:40 +0000
committerKay Tiong Khoo <kkhoo@perfwizard.com>2013-12-02 22:20:40 +0000
commit3059b474a48d4c34eb327e7f30b4de6e3d31d97a (patch)
tree19fb8a9e9a912cb5957e25f4e1aeec3de8a8e8ea /lib
parent5685c012a39dbbc81a257f7216ad52009e9abf12 (diff)
downloadllvm-3059b474a48d4c34eb327e7f30b4de6e3d31d97a.tar.gz
llvm-3059b474a48d4c34eb327e7f30b4de6e3d31d97a.tar.bz2
llvm-3059b474a48d4c34eb327e7f30b4de6e3d31d97a.tar.xz
Move variables to where they are used and give them better names. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196163 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCompares.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp
index d597885a64..a40545115d 100644
--- a/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1194,8 +1194,6 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
ConstantInt *ShAmt;
ShAmt = Shift ? dyn_cast<ConstantInt>(Shift->getOperand(1)) : 0;
- Type *Ty = Shift ? Shift->getType() : 0; // Type of the shift.
- Type *AndTy = AndCst->getType(); // Type of the and.
// We can fold this as long as we can't shift unknown bits
// into the mask. This can happen with signed shift
@@ -1210,11 +1208,15 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
if (ShiftOpcode == Instruction::AShr) {
// To test for the bad case of the signed shr, see if any
// of the bits shifted in could be tested after the mask.
- uint32_t TyBits = Ty->getPrimitiveSizeInBits();
- int ShAmtVal = TyBits - ShAmt->getLimitedValue(TyBits);
+ Type *ShiftType = Shift->getType();
+ Type *AndType = AndCst->getType();
+
+ unsigned ShiftBitWidth = ShiftType->getPrimitiveSizeInBits();
+ unsigned AndBitWidth = AndType->getPrimitiveSizeInBits();
- uint32_t BitWidth = AndTy->getPrimitiveSizeInBits();
- if ((APInt::getHighBitsSet(BitWidth, BitWidth-ShAmtVal) &
+ int ShAmtVal = ShiftBitWidth - ShAmt->getLimitedValue(ShiftBitWidth);
+
+ if ((APInt::getHighBitsSet(AndBitWidth, AndBitWidth - ShAmtVal) &
AndCst->getValue()) == 0)
CanFold = true;
} else if (ShiftOpcode == Instruction::Shl ||