diff options
author | Chris Lattner <sabre@nondot.org> | 2006-09-10 18:17:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-09-10 18:17:58 +0000 |
commit | d1f8e07808e02e9d78809c75e82957e97d7e82f0 (patch) | |
tree | cc1e434e618eb8885ec9dad4936b379fdfe3d14e /llvm/lib/Transforms/Scalar/TailDuplication.cpp | |
parent | 2e0dfb0b1639951ab03d79360b69f86cb057ec47 (diff) | |
download | bcm5719-llvm-d1f8e07808e02e9d78809c75e82957e97d7e82f0.tar.gz bcm5719-llvm-d1f8e07808e02e9d78809c75e82957e97d7e82f0.zip |
Allow tail duplication in more cases, relaxing the previous restriction a
bit. This fixes Regression/Transforms/TailDup/MergeTest.ll
llvm-svn: 30237
Diffstat (limited to 'llvm/lib/Transforms/Scalar/TailDuplication.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/TailDuplication.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/TailDuplication.cpp b/llvm/lib/Transforms/Scalar/TailDuplication.cpp index 43aaced3789..72f28aacd74 100644 --- a/llvm/lib/Transforms/Scalar/TailDuplication.cpp +++ b/llvm/lib/Transforms/Scalar/TailDuplication.cpp @@ -144,7 +144,18 @@ bool TailDup::shouldEliminateUnconditionalBranch(TerminatorInst *TI) { // if (b) // foo(); // Cloning the 'if b' block into the end of the first foo block is messy. - return false; + + // The messy case is when the fall-through block falls through to other + // blocks. This is what we would be preventing if we cloned the block. + DestI = Dest; + if (++DestI != Dest->getParent()->end()) { + BasicBlock *DestSucc = DestI; + // If any of Dest's successors are fall-throughs, don't do this xform. + for (succ_iterator SI = succ_begin(Dest), SE = succ_end(Dest); + SI != SE; ++SI) + if (*SI == DestSucc) + return false; + } } return true; |