[PATCH] D46825: [VPlan] Add moveAfter to VPRecipeBase.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 11 08:42:24 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG39d4c9fd56e3: [VPlan] Add moveAfter to VPRecipeBase. (authored by fhahn).
Herald added subscribers: psnobl, hiraditya.
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D46825?vs=146826&id=224605#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D46825/new/
https://reviews.llvm.org/D46825
Files:
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
Index: llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
===================================================================
--- llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -59,5 +59,31 @@
EXPECT_TRUE(VPBB1.empty());
}
+TEST(VPInstructionTest, moveAfter) {
+ VPInstruction *I1 = new VPInstruction(0, {});
+ VPInstruction *I2 = new VPInstruction(1, {});
+ VPInstruction *I3 = new VPInstruction(2, {});
+
+ VPBasicBlock VPBB1;
+ VPBB1.appendRecipe(I1);
+ VPBB1.appendRecipe(I2);
+ VPBB1.appendRecipe(I3);
+
+ I1->moveAfter(I2);
+
+ CHECK_ITERATOR(VPBB1, I2, I1, I3);
+
+ VPInstruction *I4 = new VPInstruction(4, {});
+ VPInstruction *I5 = new VPInstruction(5, {});
+ VPBasicBlock VPBB2;
+ VPBB2.appendRecipe(I4);
+ VPBB2.appendRecipe(I5);
+
+ I3->moveAfter(I4);
+
+ CHECK_ITERATOR(VPBB1, I2, I1);
+ CHECK_ITERATOR(VPBB2, I4, I3, I5);
+}
+
} // namespace
} // namespace llvm
Index: llvm/lib/Transforms/Vectorize/VPlan.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlan.h
+++ llvm/lib/Transforms/Vectorize/VPlan.h
@@ -615,6 +615,10 @@
/// the specified recipe.
void insertBefore(VPRecipeBase *InsertPos);
+ /// Unlink this recipe from its current VPBasicBlock and insert it into
+ /// the VPBasicBlock that MovePos lives in, right after MovePos.
+ void moveAfter(VPRecipeBase *MovePos);
+
/// This method unlinks 'this' from the containing basic block and deletes it.
///
/// \returns an iterator pointing to the element after the erased one
Index: llvm/lib/Transforms/Vectorize/VPlan.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -283,6 +283,12 @@
return getParent()->getRecipeList().erase(getIterator());
}
+void VPRecipeBase::moveAfter(VPRecipeBase *InsertPos) {
+ InsertPos->getParent()->getRecipeList().splice(
+ std::next(InsertPos->getIterator()), getParent()->getRecipeList(),
+ getIterator());
+}
+
void VPInstruction::generateInstruction(VPTransformState &State,
unsigned Part) {
IRBuilder<> &Builder = State.Builder;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46825.224605.patch
Type: text/x-patch
Size: 2270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191011/c0b30a47/attachment.bin>
More information about the llvm-commits
mailing list