[llvm] r315910 - [InstCombine] don't unnecessarily generate a constant; NFCI
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 16 07:47:24 PDT 2017
Author: spatel
Date: Mon Oct 16 07:47:24 2017
New Revision: 315910
URL: http://llvm.org/viewvc/llvm-project?rev=315910&view=rev
Log:
[InstCombine] don't unnecessarily generate a constant; NFCI
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=315910&r1=315909&r2=315910&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Oct 16 07:47:24 2017
@@ -2069,9 +2069,8 @@ Instruction *InstCombiner::foldICmpShrCo
// 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::foldICmpShrCo
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;
More information about the llvm-commits
mailing list