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 | dfa1af0513c31548ae80c82c272e7ad6878d5c15 (patch) | |
tree | 6ca38afdcee29b479ae13183461d21e8f02c1895 /lib/Transforms | |
parent | c66764c00756d800aede2fd32d55658a236b1912 (diff) |
Allow tail duplication in more cases, relaxing the previous restriction a
bit. This fixes Regression/Transforms/TailDup/MergeTest.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30237 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/TailDuplication.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index 43aaced378..72f28aacd7 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/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; |