From 42135beac86a33b3502be2837fceb73efdd0a026 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 16 Oct 2017 14:47:24 +0000 Subject: [PATCH] [InstCombine] don't unnecessarily generate a constant; NFCI llvm-svn: 315910 --- llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 04ae43ac1f4c..cb4788576c59 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/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;