[llvm] r219070 - [InstCombine] Simplify the logic from r219067 using ValueTracking

Hal Finkel hfinkel at anl.gov
Sat Oct 4 17:53:03 PDT 2014


Author: hfinkel
Date: Sat Oct  4 19:53:02 2014
New Revision: 219070

URL: http://llvm.org/viewvc/llvm-project?rev=219070&view=rev
Log:
[InstCombine] Simplify the logic from r219067 using ValueTracking

Joerg suggested on IRC that I look at generalizing the logic from r219067 to
handle more general redundancies (like removing an assume(x > 3) dominated by
an assume(x > 5)). The way to do this would be to ask ValueTracking to
determine the value of the i1 argument. It turns out that ValueTracking is not
very good at this right now (although it does get the trivial redundancy case)
because it does not understand ICmps. Nevertheless, the resulting code in
InstCombine is simpler than r219067, so we might as well do it now.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=219070&r1=219069&r2=219070&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Sat Oct  4 19:53:02 2014
@@ -1020,18 +1020,10 @@ Instruction *InstCombiner::visitCallInst
 
     // If there is a dominating assume with the same condition as this one,
     // then this one is redundant, and should be removed.
-    if (DT) {
-      for (User *U : IIOperand->users()) {
-        Instruction *User = dyn_cast<Instruction>(U);
-        if (!User || User == II)
-          continue;
-
-        if (match(User,
-                  m_Intrinsic<Intrinsic::assume>(m_Specific(IIOperand))) &&
-            DT->dominates(User, II))
-          return EraseInstFromFunction(*II);
-      }
-    }
+    APInt KnownZero(1, 0), KnownOne(1, 0);
+    computeKnownBits(IIOperand, KnownZero, KnownOne, 0, II);
+    if (KnownOne.isAllOnesValue())
+      return EraseInstFromFunction(*II);
 
     break;
   }





More information about the llvm-commits mailing list