diff options
author | Hal Finkel <hfinkel@anl.gov> | 2014-10-05 00:53:02 +0000 |
---|---|---|
committer | Hal Finkel <hfinkel@anl.gov> | 2014-10-05 00:53:02 +0000 |
commit | 4564688806fdc137a80768b3ed919ae6f0dba28b (patch) | |
tree | df8293c12ed9615201131151c721fa4d0d71c62b /llvm | |
parent | 4b92c6b8e5bf07969c9376ad5acf24ba56f06c4d (diff) | |
download | bcm5719-llvm-4564688806fdc137a80768b3ed919ae6f0dba28b.tar.gz bcm5719-llvm-4564688806fdc137a80768b3ed919ae6f0dba28b.zip |
[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.
llvm-svn: 219070
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 27a64d8bcde..c2fecde3929 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/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<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; } |