[llvm] 204252e - Revert "[VPlan] Support cloning initial VPlan (NFC)."
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun May 18 14:04:40 PDT 2025
Author: Florian Hahn
Date: 2025-05-18T22:03:00+01:00
New Revision: 204252e2df80876702616518a5154dccacf3ebac
URL: https://github.com/llvm/llvm-project/commit/204252e2df80876702616518a5154dccacf3ebac
DIFF: https://github.com/llvm/llvm-project/commit/204252e2df80876702616518a5154dccacf3ebac.diff
LOG: Revert "[VPlan] Support cloning initial VPlan (NFC)."
This reverts commit 5fa985e751c8f890fff31e190473aeeb6f7a9fc5.
Revert as this seems to introduce a call to a pure virtual function on a
few configs, e.g.
https://lab.llvm.org/buildbot/#/builders/169/builds/11535
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 15b4865d22f8e..06b738afbd221 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -1168,16 +1168,11 @@ VPlan *VPlan::duplicate() {
const auto &[NewEntry, __] = cloneFrom(Entry);
BasicBlock *ScalarHeaderIRBB = getScalarHeader()->getIRBasicBlock();
- VPIRBasicBlock *NewScalarHeader = nullptr;
- if (getScalarHeader()->getNumPredecessors() == 0) {
- NewScalarHeader = createVPIRBasicBlock(ScalarHeaderIRBB);
- } else {
- NewScalarHeader = cast<VPIRBasicBlock>(*find_if(
- vp_depth_first_shallow(NewEntry), [ScalarHeaderIRBB](VPBlockBase *VPB) {
- auto *VPIRBB = dyn_cast<VPIRBasicBlock>(VPB);
- return VPIRBB && VPIRBB->getIRBasicBlock() == ScalarHeaderIRBB;
- }));
- }
+ VPIRBasicBlock *NewScalarHeader = cast<VPIRBasicBlock>(*find_if(
+ vp_depth_first_shallow(NewEntry), [ScalarHeaderIRBB](VPBlockBase *VPB) {
+ auto *VPIRBB = dyn_cast<VPIRBasicBlock>(VPB);
+ return VPIRBB && VPIRBB->getIRBasicBlock() == ScalarHeaderIRBB;
+ }));
// Create VPlan, clone live-ins and remap operands in the cloned blocks.
auto *NewPlan = new VPlan(cast<VPBasicBlock>(NewEntry), NewScalarHeader);
DenseMap<VPValue *, VPValue *> Old2NewVPValues;
@@ -1192,7 +1187,8 @@ VPlan *VPlan::duplicate() {
NewPlan->BackedgeTakenCount = new VPValue();
Old2NewVPValues[BackedgeTakenCount] = NewPlan->BackedgeTakenCount;
}
- if (TripCount && TripCount->isLiveIn())
+ assert(TripCount && "trip count must be set");
+ if (TripCount->isLiveIn())
Old2NewVPValues[TripCount] =
NewPlan->getOrAddLiveIn(TripCount->getLiveInIRValue());
// else NewTripCount will be created and inserted into Old2NewVPValues when
@@ -1205,11 +1201,9 @@ VPlan *VPlan::duplicate() {
NewPlan->UFs = UFs;
// TODO: Adjust names.
NewPlan->Name = Name;
- if (TripCount) {
- assert(Old2NewVPValues.contains(TripCount) &&
- "TripCount must have been added to Old2NewVPValues");
- NewPlan->TripCount = Old2NewVPValues[TripCount];
- }
+ assert(Old2NewVPValues.contains(TripCount) &&
+ "TripCount must have been added to Old2NewVPValues");
+ NewPlan->TripCount = Old2NewVPValues[TripCount];
// Transfer all cloned blocks (the second half of all current blocks) from
// current to new VPlan.
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
index 129b273e376a6..f0d943fe8f304 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -904,47 +904,6 @@ No successors
EXPECT_EQ(ExpectedStr, FullDump);
}
}
-
-TEST_F(VPBasicBlockTest, cloneAndPrint) {
- VPlan &Plan = getPlan(nullptr);
- VPBasicBlock *VPBB0 = Plan.getEntry();
-
- VPInstruction *I1 = new VPInstruction(Instruction::Add, {});
- VPInstruction *I2 = new VPInstruction(Instruction::Sub, {I1});
- VPInstruction *I3 = new VPInstruction(Instruction::Br, {I1, I2});
-
- VPBasicBlock *VPBB1 = Plan.createVPBasicBlock("");
- VPBB1->appendRecipe(I1);
- VPBB1->appendRecipe(I2);
- VPBB1->appendRecipe(I3);
- VPBB1->setName("bb1");
- VPBlockUtils::connectBlocks(VPBB0, VPBB1);
-
- const char *ExpectedStr = R"(digraph VPlan {
-graph [labelloc=t, fontsize=30; label="Vectorization Plan\n for UF\>=1\n"]
-node [shape=rect, fontname=Courier, fontsize=30]
-edge [fontname=Courier, fontsize=30]
-compound=true
- N0 [label =
- "preheader:\l" +
- "Successor(s): bb1\l"
- ]
- N0 -> N1 [ label=""]
- N1 [label =
- "bb1:\l" +
- " EMIT vp\<%1\> = add\l" +
- " EMIT vp\<%2\> = sub vp\<%1\>\l" +
- " EMIT br vp\<%1\>, vp\<%2\>\l" +
- "No successors\l"
- ]
-}
-)";
- // Check that printing a cloned plan produces the same output.
- std::string FullDump;
- raw_string_ostream OS(FullDump);
- Plan.duplicate()->printDOT(OS);
- EXPECT_EQ(ExpectedStr, FullDump);
-}
#endif
using VPRecipeTest = VPlanTestBase;
More information about the llvm-commits
mailing list