diff options
author | Dan Gohman <gohman@apple.com> | 2009-05-24 19:11:38 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-05-24 19:11:38 +0000 |
commit | 95bdbfa0668cc2b475429fbc6046f364bc01edf7 (patch) | |
tree | 1001a559d29e87a6d2ed0c181d8044c4561f0dda /lib/Transforms/Scalar/IndVarSimplify.cpp | |
parent | fb5a3419f351056e0f599699d276bcab412d2cce (diff) |
When rewriting the loop exit test with the canonical induction variable,
leave the original comparison in place if it has other uses, since the
other uses won't be dominated by the new comparison instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72369 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index f20d424724..07c7d0071f 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -187,7 +187,12 @@ ICmpInst *IndVarSimplify::LinearFunctionTestReplace(Loop *L, ICmpInst *Cond = new ICmpInst(Opcode, CmpIndVar, ExitCnt, "exitcond", BI); Instruction *OrigCond = cast<Instruction>(BI->getCondition()); - OrigCond->replaceAllUsesWith(Cond); + // It's tempting to use replaceAllUsesWith here to fully replace the old + // comparison, but that's not immediately safe, since users of the old + // comparison may not be dominated by the new comparison. Instead, just + // update the branch to use the new comparison; in the common case this + // will make old comparison dead. + BI->setCondition(Cond); RecursivelyDeleteTriviallyDeadInstructions(OrigCond); ++NumLFTR; |