[llvm-commits] CVS: llvm/lib/Transforms/Scalar/TailDuplication.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Sep 10 11:18:12 PDT 2006
Changes in directory llvm/lib/Transforms/Scalar:
TailDuplication.cpp updated: 1.31 -> 1.32
---
Log message:
Allow tail duplication in more cases, relaxing the previous restriction a
bit. This fixes Regression/Transforms/TailDup/MergeTest.ll
---
Diffs of the changes: (+12 -1)
TailDuplication.cpp | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletion(-)
Index: llvm/lib/Transforms/Scalar/TailDuplication.cpp
diff -u llvm/lib/Transforms/Scalar/TailDuplication.cpp:1.31 llvm/lib/Transforms/Scalar/TailDuplication.cpp:1.32
--- llvm/lib/Transforms/Scalar/TailDuplication.cpp:1.31 Thu Sep 7 16:30:15 2006
+++ llvm/lib/Transforms/Scalar/TailDuplication.cpp Sun Sep 10 13:17:58 2006
@@ -144,7 +144,18 @@
// 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;
More information about the llvm-commits
mailing list