aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-19 18:38:44 +0000
committerChris Lattner <sabre@nondot.org>2010-12-19 18:38:44 +0000
commit0fe80bbbb6a017169d273c4824903b52a7ea2414 (patch)
tree303c2e9ff365c882b5d45177d21c54e50f6d5f59
parent0a62474830f50b423329470caeb9a4e4da14a607 (diff)
use IC.ReplaceInstUsesWith instead of a raw RAUW so that uses of
the old thing end up on the instcombine worklist. Not doing this can cause an extra top-level iteration of instcombine, burning compile time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122179 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/InstCombine/InstCombineCompares.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 9f0fa3e740..86a0ed2652 100644
--- a/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1592,7 +1592,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
///
static Instruction *ProcessUGT_ADDCST_ADD(ICmpInst &I, Value *A, Value *B,
ConstantInt *CI2, ConstantInt *CI1,
- InstCombiner::BuilderTy *Builder) {
+ InstCombiner &IC) {
// The transformation we're trying to do here is to transform this into an
// llvm.sadd.with.overflow. To do this, we have to replace the original add
// with a narrower add, and discard the add-with-constant that is part of the
@@ -1644,6 +1644,8 @@ static Instruction *ProcessUGT_ADDCST_ADD(ICmpInst &I, Value *A, Value *B,
Value *F = Intrinsic::getDeclaration(M, Intrinsic::sadd_with_overflow,
&NewType, 1);
+ InstCombiner::BuilderTy *Builder = IC.Builder;
+
// Put the new code above the original add, in case there are any uses of the
// add between the add and the compare.
Builder->SetInsertPoint(OrigAdd->getParent(), BasicBlock::iterator(OrigAdd));
@@ -1656,7 +1658,7 @@ static Instruction *ProcessUGT_ADDCST_ADD(ICmpInst &I, Value *A, Value *B,
// The inner add was the result of the narrow add, zero extended to the
// wider type. Replace it with the result computed by the intrinsic.
- OrigAdd->replaceAllUsesWith(ZExt);
+ IC.ReplaceInstUsesWith(*OrigAdd, ZExt);
// The original icmp gets replaced with the overflow value.
return ExtractValueInst::Create(Call, 1, "sadd.overflow");
@@ -1751,7 +1753,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
ConstantInt *CI2; // I = icmp ugt (add (add A, B), CI2), CI
if (I.getPredicate() == ICmpInst::ICMP_UGT &&
match(Op0, m_Add(m_Add(m_Value(A), m_Value(B)), m_ConstantInt(CI2))))
- if (Instruction *Res = ProcessUGT_ADDCST_ADD(I, A, B, CI2, CI, Builder))
+ if (Instruction *Res = ProcessUGT_ADDCST_ADD(I, A, B, CI2, CI, *this))
return Res;
}