Get the number of bits to set in a mask correct for a shl/lshr transform.
[oota-llvm.git] / lib / Transforms / Scalar / InstructionCombining.cpp
index 586c7b1fb10cb0a9ded11d9f880b40b8a962d71c..78446bc67fb963c7e586e975bfda0450bded36ea 100644 (file)
@@ -5858,7 +5858,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
           BinaryOperator::createLShr(X, ConstantInt::get(Ty, ShiftDiff));
         InsertNewInstBefore(Shift, I);
         
-        APInt Mask(APInt::getLowBitsSet(TypeBits, ShiftAmt2));
+        APInt Mask(APInt::getLowBitsSet(TypeBits, TypeBits - ShiftAmt2));
         return BinaryOperator::createAnd(Shift, ConstantInt::get(Mask));
       }