Skip to content

Commit 8b03786

Browse files
authored
[VPlan] Preserve DT (and SCEV) in VPlan-native path (#93287)
As a follow-up to b2f65e8, use the DTU to also update and preserve the DT in the native path. This should also allow preserving SCEV in the native path PR: #93287
1 parent 57c10fa commit 8b03786

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7507,9 +7507,8 @@ LoopVectorizationPlanner::executePlan(
75077507
LLVM_DEBUG(BestVPlan.dump());
75087508

75097509
// Perform the actual loop transformation.
7510-
VPTransformState State(BestVF, BestUF, LI,
7511-
EnableVPlanNativePath ? nullptr : DT, ILV.Builder,
7512-
&ILV, &BestVPlan, OrigLoop->getHeader()->getContext());
7510+
VPTransformState State(BestVF, BestUF, LI, DT, ILV.Builder, &ILV, &BestVPlan,
7511+
OrigLoop->getHeader()->getContext());
75137512

75147513
// 0. Generate SCEV-dependent code into the preheader, including TripCount,
75157514
// before making any changes to the CFG.
@@ -10370,16 +10369,9 @@ PreservedAnalyses LoopVectorizePass::run(Function &F,
1037010369
RemoveRedundantDbgInstrs(&BB);
1037110370
}
1037210371

10373-
// We currently do not preserve dominator analyses with outer loop
10374-
// vectorization. Until this is addressed, mark these analyses as preserved
10375-
// only for non-VPlan-native path.
10376-
// TODO: Preserve Dominator analysis for VPlan-native path.
10377-
if (!EnableVPlanNativePath) {
10378-
PA.preserve<DominatorTreeAnalysis>();
10379-
PA.preserve<ScalarEvolutionAnalysis>();
10380-
}
10381-
1038210372
PA.preserve<LoopAnalysis>();
10373+
PA.preserve<DominatorTreeAnalysis>();
10374+
PA.preserve<ScalarEvolutionAnalysis>();
1038310375

1038410376
if (Result.MadeCFGChange) {
1038510377
// Making CFG changes likely means a loop got vectorized. Indicate that

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,9 +900,9 @@ void VPlan::execute(VPTransformState *State) {
900900
}
901901

902902
State->CFG.DTU.flush();
903-
// DT is currently updated for non-native path only.
904-
assert(EnableVPlanNativePath || State->CFG.DTU.getDomTree().verify(
905-
DominatorTree::VerificationLevel::Fast));
903+
assert(State->CFG.DTU.getDomTree().verify(
904+
DominatorTree::VerificationLevel::Fast) &&
905+
"DT not preserved correctly");
906906
}
907907

908908
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

llvm/test/Transforms/LoopVectorize/outer_loop_test1.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
; }
1414
; }
1515
;
16-
; RUN: opt -S -passes=loop-vectorize -enable-vplan-native-path -verify-loop-info < %s | FileCheck %s
16+
; RUN: opt -S -passes=loop-vectorize -enable-vplan-native-path -verify-loop-info -verify-dom-info < %s | FileCheck %s
1717
; CHECK-LABEL: vector.ph:
1818
; CHECK: %[[SplatVal:.*]] = insertelement <4 x i32> poison, i32 %n, i64 0
1919
; CHECK: %[[Splat:.*]] = shufflevector <4 x i32> %[[SplatVal]], <4 x i32> poison, <4 x i32> zeroinitializer

0 commit comments

Comments
 (0)