From 50eafbc828610b16e4324c777ac4e5d82b0676cc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 16 Mar 2004 23:36:49 +0000 Subject: [PATCH] Fix bug in previous checkin git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12458 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/TailDuplication.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index 45f0543fb29..40821e450c6 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/lib/Transforms/Scalar/TailDuplication.cpp @@ -157,8 +157,13 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) { } } else if (PHINode *PN = dyn_cast(cast(*UI))) { // If the user of this instruction is a PHI node in the current block, - // spill the value. - ShouldDemote = true; + // which has an entry from another block using the value, spill it. + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) + if (PN->getIncomingValue(i) == I && + PN->getIncomingBlock(i) != DestBlock) { + ShouldDemote = true; + break; + } } if (ShouldDemote) {