[llvm-commits] [llvm] r122179 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Chris Lattner
sabre at nondot.org
Sun Dec 19 10:38:44 PST 2010
Author: lattner
Date: Sun Dec 19 12:38:44 2010
New Revision: 122179
URL: http://llvm.org/viewvc/llvm-project?rev=122179&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=122179&r1=122178&r2=122179&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Sun Dec 19 12:38:44 2010
@@ -1592,7 +1592,7 @@
///
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 @@
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 @@
// 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 @@
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;
}
More information about the llvm-commits
mailing list