diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 2b0c31bfef8c1..c37fa3f75c234 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -829,8 +829,8 @@ static llvm::Value *EmitCXXNewAllocSize(CodeGenFunction &CGF, // going to have to do a comparison for (2), and this happens to // take care of (1), too. if (numElementsWidth > sizeWidth) { - llvm::APInt threshold(numElementsWidth, 1); - threshold <<= sizeWidth; + llvm::APInt threshold = + llvm::APInt::getOneBitSet(numElementsWidth, sizeWidth); llvm::Value *thresholdV = llvm::ConstantInt::get(numElementsType, threshold); diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 55f716a45ca91..156b1c9ba6199 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -8811,8 +8811,7 @@ SDValue TargetLowering::expandBITREVERSE(SDNode *N, SelectionDAG &DAG) const { Tmp2 = DAG.getNode(ISD::SRL, dl, VT, Op, DAG.getConstant(I - J, dl, SHVT)); - APInt Shift(Sz, 1); - Shift <<= J; + APInt Shift = APInt::getOneBitSet(Sz, J); Tmp2 = DAG.getNode(ISD::AND, dl, VT, Tmp2, DAG.getConstant(Shift, dl, VT)); Tmp = DAG.getNode(ISD::OR, dl, VT, Tmp, Tmp2); }