Skip to content

Commit af0be76

Browse files
authored
[VPlan] Replace reverse RPOT with PO traversal (NFC) (#151757)
1 parent 44500ae commit af0be76

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlanCFG.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ vp_post_order_shallow(VPBlockBase *G) {
230230
return post_order(VPBlockShallowTraversalWrapper<VPBlockBase *>(G));
231231
}
232232

233+
/// Returns an iterator range to traverse the graph starting at \p G in
234+
/// post order while traversing through region blocks.
235+
inline iterator_range<po_iterator<VPBlockDeepTraversalWrapper<VPBlockBase *>>>
236+
vp_post_order_deep(VPBlockBase *G) {
237+
return post_order(VPBlockDeepTraversalWrapper<VPBlockBase *>(G));
238+
}
239+
233240
/// Returns an iterator range to traverse the graph starting at \p G in
234241
/// depth-first order while traversing through region blocks.
235242
inline iterator_range<df_iterator<VPBlockDeepTraversalWrapper<VPBlockBase *>>>

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,8 @@ static bool isDeadRecipe(VPRecipeBase &R) {
545545
}
546546

547547
void VPlanTransforms::removeDeadRecipes(VPlan &Plan) {
548-
ReversePostOrderTraversal<VPBlockDeepTraversalWrapper<VPBlockBase *>> RPOT(
549-
Plan.getEntry());
550-
551-
for (VPBasicBlock *VPBB : reverse(VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT))) {
548+
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
549+
vp_post_order_deep(Plan.getEntry()))) {
552550
// The recipes in the block are processed in reverse order, to catch chains
553551
// of dead recipes.
554552
for (VPRecipeBase &R : make_early_inc_range(reverse(*VPBB))) {

0 commit comments

Comments
 (0)