Skip to content

Commit

Permalink
[LV] Remove implicit single basic block assumption
Browse files Browse the repository at this point in the history
This patch is part of D28975's breakdown - no change in output intended.

LV's code currently assumes the vectorized loop is a single basic block up
until predicateInstructions() is called. This patch removes two manifestations
of this assumption (loop phi incoming values, dominator tree update) by
replacing the use of vectorLoopBody with the vectorized loop's latch/header.

Differential Revision: https://reviews.llvm.org/D32040

llvm-svn: 300310
  • Loading branch information
aniragil committed Apr 14, 2017
1 parent 66df10f commit 334f8fb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Expand Up @@ -4200,7 +4200,7 @@ void InnerLoopVectorizer::fixReduction(PHINode *Phi) {
cast<PHINode>(VecRdxPhi[part])
->addIncoming(StartVal, LoopVectorPreHeader);
cast<PHINode>(VecRdxPhi[part])
->addIncoming(Val[part], LoopVectorBody);
->addIncoming(Val[part], LI->getLoopFor(LoopVectorBody)->getLoopLatch());
}

// Before each round, move the insertion point right between
Expand Down Expand Up @@ -5059,11 +5059,10 @@ void InnerLoopVectorizer::updateAnalysis() {
assert(DT->properlyDominates(LoopBypassBlocks.front(), LoopExitBlock) &&
"Entry does not dominate exit.");

// We don't predicate stores by this point, so the vector body should be a
// single loop.
DT->addNewBlock(LoopVectorBody, LoopVectorPreHeader);

DT->addNewBlock(LoopMiddleBlock, LoopVectorBody);
DT->addNewBlock(LI->getLoopFor(LoopVectorBody)->getHeader(),
LoopVectorPreHeader);
DT->addNewBlock(LoopMiddleBlock,
LI->getLoopFor(LoopVectorBody)->getLoopLatch());
DT->addNewBlock(LoopScalarPreHeader, LoopBypassBlocks[0]);
DT->changeImmediateDominator(LoopScalarBody, LoopScalarPreHeader);
DT->changeImmediateDominator(LoopExitBlock, LoopBypassBlocks[0]);
Expand Down

0 comments on commit 334f8fb

Please sign in to comment.