OSDN Git Service

[InstCombine] remove an icmp fold that is already handled by InstSimplify
authorSanjay Patel <spatel@rotateright.com>
Fri, 19 Aug 2016 19:03:07 +0000 (19:03 +0000)
committerSanjay Patel <spatel@rotateright.com>
Fri, 19 Aug 2016 19:03:07 +0000 (19:03 +0000)
Specifically, this is done near the end of "SimplifyICmpInst" using
computeKnownBits() as the broader solution. There are even vector
tests (yay!) for this in test/Transforms/InstSimplify/compare.ll.

I considered putting an assert here instead of just deleting, but
then we could assert every possible fold in InstSimplify in
InstCombine, so...less is more?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279300 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineCompares.cpp

index 2558773..f9a7eb2 100644 (file)
@@ -2009,16 +2009,6 @@ Instruction *InstCombiner::foldICmpShlConstant(ICmpInst &Cmp, Instruction *Shl,
   ICmpInst::Predicate Pred = Cmp.getPredicate();
   Value *X = Shl->getOperand(0);
   if (Cmp.isEquality()) {
-    // If we are comparing against bits always shifted out, the comparison
-    // cannot succeed.
-    Constant *Comp =
-        ConstantExpr::getShl(ConstantExpr::getLShr(RHS, ShAmt), ShAmt);
-    if (Comp != RHS) { // Comparing against a bit that we know is zero.
-      bool IsICMP_NE = Pred == ICmpInst::ICMP_NE;
-      Constant *Cst = Builder->getInt1(IsICMP_NE);
-      return replaceInstUsesWith(Cmp, Cst);
-    }
-
     // If the shift is NUW, then it is just shifting out zeros, no need for an
     // AND.
     if (cast<BinaryOperator>(Shl)->hasNoUnsignedWrap())