From 4ff71362683b159903b3908f5c9f949d2fe7656d Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Mon, 12 Oct 2020 18:39:30 +0100 Subject: [PATCH] [InstCombine] FoldShiftByConstant - create Scalar/Vector constant with ConstantInt::get(). NFCI. There's no need to create constant vector splats manually - missed this one in rG24dd0cd1edd5 --- llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp index 9f52f08d3a4d..b28dc490cbde 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -776,11 +776,8 @@ Instruction *InstCombinerImpl::FoldShiftByConstant(Value *Op0, Constant *Op1, Value *X = Builder.CreateBinOp(Op0BO->getOpcode(), V1, YS, Op0BO->getOperand(0)->getName()); unsigned Op1Val = Op1C->getLimitedValue(TypeBits); - APInt Bits = APInt::getHighBitsSet(TypeBits, TypeBits - Op1Val); - Constant *Mask = ConstantInt::get(I.getContext(), Bits); - if (VectorType *VT = dyn_cast(X->getType())) - Mask = ConstantVector::getSplat(VT->getElementCount(), Mask); + Constant *Mask = ConstantInt::get(Ty, Bits); return BinaryOperator::CreateAnd(X, Mask); }