[PATCH] D32040: [LV] Remove implicit single basic block assumption

Gil Rapaport via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 13 12:55:45 PDT 2017


gilr created this revision.
Herald added a subscriber: mzolotukhin.

This patch is part of D28975 <https://reviews.llvm.org/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 by replacing the use of vectorLoopBody with the vectorized loop's latch.


https://reviews.llvm.org/D32040

Files:
  lib/Transforms/Vectorize/LoopVectorize.cpp


Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4190,7 +4190,7 @@
     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
@@ -5053,7 +5053,8 @@
   // single loop.
   DT->addNewBlock(LoopVectorBody, LoopVectorPreHeader);
 
-  DT->addNewBlock(LoopMiddleBlock, LoopVectorBody);
+  DT->addNewBlock(LoopMiddleBlock,
+                  LI->getLoopFor(LoopVectorBody)->getLoopLatch());
   DT->addNewBlock(LoopScalarPreHeader, LoopBypassBlocks[0]);
   DT->changeImmediateDominator(LoopScalarBody, LoopScalarPreHeader);
   DT->changeImmediateDominator(LoopExitBlock, LoopBypassBlocks[0]);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32040.95178.patch
Type: text/x-patch
Size: 1018 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170413/099c9efa/attachment.bin>


More information about the llvm-commits mailing list