Move variables to where they are used and give them better names. No functional change intended.

llvm-svn: 196163
This commit is contained in:
Kay Tiong Khoo 2013-12-02 22:20:40 +00:00
parent 14489a85ab
commit 40a987d7ca

View File

@ -1194,8 +1194,6 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
ConstantInt *ShAmt; ConstantInt *ShAmt;
ShAmt = Shift ? dyn_cast<ConstantInt>(Shift->getOperand(1)) : 0; 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 // We can fold this as long as we can't shift unknown bits
// into the mask. This can happen with signed shift // into the mask. This can happen with signed shift
@ -1210,11 +1208,15 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
if (ShiftOpcode == Instruction::AShr) { if (ShiftOpcode == Instruction::AShr) {
// To test for the bad case of the signed shr, see if any // To test for the bad case of the signed shr, see if any
// of the bits shifted in could be tested after the mask. // of the bits shifted in could be tested after the mask.
uint32_t TyBits = Ty->getPrimitiveSizeInBits(); Type *ShiftType = Shift->getType();
int ShAmtVal = TyBits - ShAmt->getLimitedValue(TyBits); Type *AndType = AndCst->getType();
unsigned ShiftBitWidth = ShiftType->getPrimitiveSizeInBits();
unsigned AndBitWidth = AndType->getPrimitiveSizeInBits();
uint32_t BitWidth = AndTy->getPrimitiveSizeInBits(); int ShAmtVal = ShiftBitWidth - ShAmt->getLimitedValue(ShiftBitWidth);
if ((APInt::getHighBitsSet(BitWidth, BitWidth-ShAmtVal) &
if ((APInt::getHighBitsSet(AndBitWidth, AndBitWidth - ShAmtVal) &
AndCst->getValue()) == 0) AndCst->getValue()) == 0)
CanFold = true; CanFold = true;
} else if (ShiftOpcode == Instruction::Shl || } else if (ShiftOpcode == Instruction::Shl ||