aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-01-02 07:58:36 +0000
committerChris Lattner <sabre@nondot.org>2011-01-02 07:58:36 +0000
commitcf078f2b20899a3a19fb2044cc08dff409f13276 (patch)
tree10d9344a15babd779c7bf7ceb7385c7f78d6e2e6 /lib/Transforms
parentc9e152b778715afc5cdfdb98cb0e98757ed827d8 (diff)
Allow loop-idiom to run on multiple BB loops, but still only scan the loop
header for now for memset/memcpy opportunities. It turns out that loop-rotate is successfully rotating loops, but *DOESN'T MERGE THE BLOCKS*, turning "for loops" into 2 basic block loops that loop-idiom was ignoring. With this fix, we form many *many* more memcpy and memsets than before, including on the "history" loops in the viterbi benchmark, which look like this: for (j=0; j<MAX_history; ++j) { history_new[i][j+1] = history[2*i][j]; } Transforming these loops into memcpy's speeds up the viterbi benchmark from 11.98s to 3.55s on my machine. Woo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122685 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/LoopIdiomRecognize.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index e9394cd5c0..84e33f062b 100644
--- a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -126,11 +126,6 @@ static void DeleteDeadInstruction(Instruction *I, ScalarEvolution &SE) {
bool LoopIdiomRecognize::runOnLoop(Loop *L, LPPassManager &LPM) {
CurLoop = L;
- // We only look at trivial single basic block loops.
- // TODO: eventually support more complex loops, scanning the header.
- if (L->getBlocks().size() != 1)
- return false;
-
// The trip count of the loop must be analyzable.
SE = &getAnalysis<ScalarEvolution>();
if (!SE->hasLoopInvariantBackedgeTakenCount(L))
@@ -142,6 +137,11 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L, LPPassManager &LPM) {
TD = getAnalysisIfAvailable<TargetData>();
if (TD == 0) return false;
+ // TODO: We currently only scan the header of the loop, because it is the only
+ // part that is known to execute and we don't want to make a conditional store
+ // into an unconditional one in the preheader. However, there can be diamonds
+ // and other things in the loop that would make other blocks "always executed"
+ // we should get the full set and scan each block.
BasicBlock *BB = L->getHeader();
DEBUG(dbgs() << "loop-idiom Scanning: F[" << BB->getParent()->getName()
<< "] Loop %" << BB->getName() << "\n");