From: Hal Finkel Date: Sun, 5 Oct 2014 00:53:02 +0000 (+0000) Subject: [InstCombine] Simplify the logic from r219067 using ValueTracking X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=bda7a45f8eaa68d994519e85c30844f27702ec26 [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219070 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index 27a64d8bcde..c2fecde3929 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1020,18 +1020,10 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { // 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(U); - if (!User || User == II) - continue; - - if (match(User, - m_Intrinsic(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; }