[llvm] 32928a0 - [VPlan] Construct regions from innermost to outermost (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue May 6 12:51:36 PDT 2025
Author: Florian Hahn
Date: 2025-05-06T20:49:24+01:00
New Revision: 32928a07846bd531ef31f1166faa4e119be4f15f
URL: https://github.com/llvm/llvm-project/commit/32928a07846bd531ef31f1166faa4e119be4f15f
DIFF: https://github.com/llvm/llvm-project/commit/32928a07846bd531ef31f1166faa4e119be4f15f.diff
LOG: [VPlan] Construct regions from innermost to outermost (NFC).
Flip the region construction order to innermost first from outermost
first. This ensures we only set the final parent region for VPBBs once.
Split off from https://github.com/llvm/llvm-project/pull/137709.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanCFG.h
llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanCFG.h b/llvm/lib/Transforms/Vectorize/VPlanCFG.h
index a1014c398789f..b77aa9d710ef0 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanCFG.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanCFG.h
@@ -16,6 +16,7 @@
#include "VPlanUtils.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/GraphTraits.h"
+#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/SmallVector.h"
namespace llvm {
@@ -221,6 +222,14 @@ vp_depth_first_shallow(const VPBlockBase *G) {
return depth_first(VPBlockShallowTraversalWrapper<const VPBlockBase *>(G));
}
+/// Returns an iterator range to traverse the graph starting at \p G in
+/// post order. The iterator won't traverse through region blocks.
+inline iterator_range<
+ po_iterator<VPBlockShallowTraversalWrapper<VPBlockBase *>>>
+vp_post_order_shallow(VPBlockBase *G) {
+ return post_order(VPBlockShallowTraversalWrapper<VPBlockBase *>(G));
+}
+
/// Returns an iterator range to traverse the graph starting at \p G in
/// depth-first order while traversing through region blocks.
inline iterator_range<df_iterator<VPBlockDeepTraversalWrapper<VPBlockBase *>>>
diff --git a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
index 85070565718da..da4dc4881db53 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
@@ -559,7 +559,7 @@ void VPlanTransforms::prepareForVectorization(VPlan &Plan, Type *InductionTy,
void VPlanTransforms::createLoopRegions(VPlan &Plan) {
VPDominatorTree VPDT;
VPDT.recalculate(Plan);
- for (VPBlockBase *HeaderVPB : vp_depth_first_shallow(Plan.getEntry()))
+ for (VPBlockBase *HeaderVPB : vp_post_order_shallow(Plan.getEntry()))
if (canonicalHeaderAndLatch(HeaderVPB, VPDT))
createLoopRegion(Plan, HeaderVPB);
More information about the llvm-commits
mailing list