diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-20 22:18:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-20 22:18:22 +0000 |
commit | 567166c0a8bd35c44f7d0e8fce5392e6fe249421 (patch) | |
tree | 6bcf3a037c19d7060af7c92e476c6f618ce594cb /llvm/lib/Transforms/Scalar/TailDuplication.cpp | |
parent | 8ec6e8af60312f1ba3eceee8e73f9231b9f0a29e (diff) | |
download | bcm5719-llvm-567166c0a8bd35c44f7d0e8fce5392e6fe249421.tar.gz bcm5719-llvm-567166c0a8bd35c44f7d0e8fce5392e6fe249421.zip |
replace a slow and verbose version of Instruction::isUsedOutsideOfBlock with
a call to Instruction::isUsedOutsideOfBlock.
llvm-svn: 50005
Diffstat (limited to 'llvm/lib/Transforms/Scalar/TailDuplication.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/TailDuplication.cpp | 38 |
1 files changed, 4 insertions, 34 deletions
diff --git a/llvm/lib/Transforms/Scalar/TailDuplication.cpp b/llvm/lib/Transforms/Scalar/TailDuplication.cpp index 929d1137450..f9b8ace11f3 100644 --- a/llvm/lib/Transforms/Scalar/TailDuplication.cpp +++ b/llvm/lib/Transforms/Scalar/TailDuplication.cpp @@ -264,40 +264,10 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) { // this reason, we spill all values that are used outside of the tail to the // stack. for (BasicBlock::iterator I = DestBlock->begin(); I != DestBlock->end(); ++I) - for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; - ++UI) { - bool ShouldDemote = false; - if (cast<Instruction>(*UI)->getParent() != DestBlock) { - // We must allow our successors to use tail values in their PHI nodes - // (if the incoming value corresponds to the tail block). - if (PHINode *PN = dyn_cast<PHINode>(*UI)) { - for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) - if (PN->getIncomingValue(i) == I && - PN->getIncomingBlock(i) != DestBlock) { - ShouldDemote = true; - break; - } - - } else { - ShouldDemote = true; - } - } else if (PHINode *PN = dyn_cast<PHINode>(cast<Instruction>(*UI))) { - // If the user of this instruction is a PHI node in the current block, - // 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) { - // We found a use outside of the tail. Create a new stack slot to - // break this inter-block usage pattern. - DemoteRegToStack(*I); - break; - } + if (I->isUsedOutsideOfBlock(DestBlock)) { + // We found a use outside of the tail. Create a new stack slot to + // break this inter-block usage pattern. + DemoteRegToStack(*I); } // We are going to have to map operands from the original block B to the new |