Skip to content

Commit 9277a32

Browse files
committed
[VPlan] Funnel recipe insert* through VPBasicBlock::insert (NFCI).
This allows relying on VPBasicBlock::insert to make sure insertion is well formed, i.e. by updating the recipe's parent as well as other potential invariants in the future.
1 parent 0ef61ed commit 9277a32

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,24 +198,21 @@ void VPRecipeBase::insertBefore(VPRecipeBase *InsertPos) {
198198
assert(!Parent && "Recipe already in some VPBasicBlock");
199199
assert(InsertPos->getParent() &&
200200
"Insertion position not in any VPBasicBlock");
201-
Parent = InsertPos->getParent();
202-
Parent->getRecipeList().insert(InsertPos->getIterator(), this);
201+
InsertPos->getParent()->insert(this, InsertPos->getIterator());
203202
}
204203

205204
void VPRecipeBase::insertBefore(VPBasicBlock &BB,
206205
iplist<VPRecipeBase>::iterator I) {
207206
assert(!Parent && "Recipe already in some VPBasicBlock");
208207
assert(I == BB.end() || I->getParent() == &BB);
209-
Parent = &BB;
210-
BB.getRecipeList().insert(I, this);
208+
BB.insert(this, I);
211209
}
212210

213211
void VPRecipeBase::insertAfter(VPRecipeBase *InsertPos) {
214212
assert(!Parent && "Recipe already in some VPBasicBlock");
215213
assert(InsertPos->getParent() &&
216214
"Insertion position not in any VPBasicBlock");
217-
Parent = InsertPos->getParent();
218-
Parent->getRecipeList().insertAfter(InsertPos->getIterator(), this);
215+
InsertPos->getParent()->insert(this, std::next(InsertPos->getIterator()));
219216
}
220217

221218
void VPRecipeBase::removeFromParent() {

0 commit comments

Comments
 (0)