[llvm] r196163 - Move variables to where they are used and give them better names. No functional change intended.

Kay Tiong Khoo kkhoo at perfwizard.com
Mon Dec 2 14:20:40 PST 2013


Author: kkhoo
Date: Mon Dec  2 16:20:40 2013
New Revision: 196163

URL: http://llvm.org/viewvc/llvm-project?rev=196163&view=rev
Log:
Move variables to where they are used and give them better names. No functional change intended.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=196163&r1=196162&r2=196163&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Dec  2 16:20:40 2013
@@ -1194,8 +1194,6 @@ Instruction *InstCombiner::visitICmpInst
 
       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::visitICmpInst
         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 ||





More information about the llvm-commits mailing list