From: Sanjay Patel Date: Mon, 16 Oct 2017 14:47:24 +0000 (+0000) Subject: [InstCombine] don't unnecessarily generate a constant; NFCI X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3cf64e346f014152e2b7e286f8873a4a6cb405ac;p=llvm [InstCombine] don't unnecessarily generate a constant; NFCI git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315910 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index 04ae43ac1f4..cb4788576c5 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -2069,9 +2069,8 @@ Instruction *InstCombiner::foldICmpShrConstant(ICmpInst &Cmp, // If the bits shifted out are known zero, compare the unshifted value: // (X & 4) >> 1 == 2 --> (X & 4) == 4. - Constant *ShiftedCmpRHS = ConstantInt::get(ShrTy, C << ShAmtVal); if (Shr->isExact()) - return new ICmpInst(Pred, X, ShiftedCmpRHS); + return new ICmpInst(Pred, X, ConstantInt::get(ShrTy, C << ShAmtVal)); if (Shr->hasOneUse()) { // Canonicalize the shift into an 'and': @@ -2079,7 +2078,7 @@ Instruction *InstCombiner::foldICmpShrConstant(ICmpInst &Cmp, APInt Val(APInt::getHighBitsSet(TypeBits, TypeBits - ShAmtVal)); Constant *Mask = ConstantInt::get(ShrTy, Val); Value *And = Builder.CreateAnd(X, Mask, Shr->getName() + ".mask"); - return new ICmpInst(Pred, And, ShiftedCmpRHS); + return new ICmpInst(Pred, And, ConstantInt::get(ShrTy, C << ShAmtVal)); } return nullptr;