]> granicus.if.org Git - llvm/commitdiff
[InstCombine] don't unnecessarily generate a constant; NFCI
authorSanjay Patel <spatel@rotateright.com>
Mon, 16 Oct 2017 14:47:24 +0000 (14:47 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 16 Oct 2017 14:47:24 +0000 (14:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315910 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineCompares.cpp

index 04ae43ac1f4c53c5e8fba87f2db6950fee976b7a..cb4788576c59a54778c72d87b9f67d1edd84aeb7 100644 (file)
@@ -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;