[PATCH] D32224: [LV] Remove redundant basic block split
Gil Rapaport via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 19 07:31:39 PDT 2017
gilr created this revision.
Herald added a subscriber: mzolotukhin.
This patch is part of D28975 <https://reviews.llvm.org/D28975>'s breakdown.
The process of generating the control flow guarding predicated instructions includes:
(1) a call to SplitBlock(), which splits the basic block after the predicated instruction, producing:
--> HEAD --> PRED --> TAIL -->
(2) a call to SplitBblockAndInsertIfThen() which splits the basic block before the predicated instruction into a "triangle", resulting
in a redundant basic block with an unconditional branch:
--> HEAD --> PRED --> MERGE --> TAIL -->
+----------------------^
By removing (1) we get:
--> HEAD --> PRED --> MERGE/TAIL -->
+--------------------^
https://reviews.llvm.org/D32224
Files:
lib/Transforms/Vectorize/LoopVectorize.cpp
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4516,14 +4516,15 @@
for (auto KV : PredicatedInstructions) {
BasicBlock::iterator I(KV.first);
BasicBlock *Head = I->getParent();
- auto *BB = SplitBlock(Head, &*std::next(I), DT, LI);
auto *T = SplitBlockAndInsertIfThen(KV.second, &*I, /*Unreachable=*/false,
/*BranchWeights=*/nullptr, DT, LI);
I->moveBefore(T);
sinkScalarOperands(&*I);
- I->getParent()->setName(Twine("pred.") + I->getOpcodeName() + ".if");
- BB->setName(Twine("pred.") + I->getOpcodeName() + ".continue");
+ BasicBlock *PredicatedBlock = I->getParent();
+ Twine BBNamePrefix = Twine("pred.") + I->getOpcodeName();
+ PredicatedBlock->setName(BBNamePrefix + ".if");
+ PredicatedBlock->getSingleSuccessor()->setName(BBNamePrefix + ".continue");
// If the instruction is non-void create a Phi node at reconvergence point.
if (!I->getType()->isVoidTy()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32224.95732.patch
Type: text/x-patch
Size: 1142 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170419/0032ab20/attachment.bin>
More information about the llvm-commits
mailing list