diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 61acad04f32..f8f0573395d 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1294,6 +1294,10 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, ShVal = InsertNewInstBefore(new ShiftInst(Instruction::Shr, ShVal, OpRHS, Op->getName()), TheAnd); + Value *AndRHS2 = ConstantExpr::getCast(AndRHS, ShVal->getType()); + ShVal = InsertNewInstBefore(BinaryOperator::createAnd(ShVal, AndRHS2, + TheAnd.getName()), + TheAnd); return new CastInst(ShVal, Op->getType()); } }