From: Simon Pilgrim Date: Tue, 17 Sep 2019 10:51:30 +0000 (+0000) Subject: [X86] Use APInt::getLowBitsSet helper. NFCI. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1592a6777e72574e35d71bb1ac56484738bda10;p=llvm [X86] Use APInt::getLowBitsSet helper. NFCI. Also avoids a static analyzer warning about out of range shifts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372103 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 58b1d47aa2c..b0c64a1bd8a 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -20301,7 +20301,8 @@ X86TargetLowering::BuildSDIVPow2(SDNode *N, const APInt &Divisor, SDLoc DL(N); SDValue N0 = N->getOperand(0); SDValue Zero = DAG.getConstant(0, DL, VT); - SDValue Pow2MinusOne = DAG.getConstant((1ULL << Lg2) - 1, DL, VT); + APInt Lg2Mask = APInt::getLowBitsSet(VT.getSizeInBits(), Lg2); + SDValue Pow2MinusOne = DAG.getConstant(Lg2Mask, DL, VT); // If N0 is negative, we need to add (Pow2 - 1) to it before shifting right. SDValue Cmp = DAG.getSetCC(DL, MVT::i8, N0, Zero, ISD::SETLT);