aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2024-05-27 17:03:53 -0700
committerGitHub <noreply@github.com>2024-05-27 17:03:53 -0700
commit8b037862b6eabe2efd4b0dcfdb6768484cd10564 (patch)
treeb838803b60576969bc505c7c1414ab43c0099a4d /llvm
parent57c10fa564af44a5b236bc642c540d715b04448c (diff)
downloadllvm-8b037862b6eabe2efd4b0dcfdb6768484cd10564.zip
llvm-8b037862b6eabe2efd4b0dcfdb6768484cd10564.tar.gz
llvm-8b037862b6eabe2efd4b0dcfdb6768484cd10564.tar.bz2
[VPlan] Preserve DT (and SCEV) in VPlan-native path (#93287)
As a follow-up to b2f65e80, 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: https://github.com/llvm/llvm-project/pull/93287
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp16
-rw-r--r--llvm/lib/Transforms/Vectorize/VPlan.cpp6
-rw-r--r--llvm/test/Transforms/LoopVectorize/outer_loop_test1.ll2
3 files changed, 8 insertions, 16 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 48981a6..e20073d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7507,9 +7507,8 @@ LoopVectorizationPlanner::executePlan(
LLVM_DEBUG(BestVPlan.dump());
// Perform the actual loop transformation.
- VPTransformState State(BestVF, BestUF, LI,
- EnableVPlanNativePath ? nullptr : DT, ILV.Builder,
- &ILV, &BestVPlan, OrigLoop->getHeader()->getContext());
+ VPTransformState State(BestVF, BestUF, LI, DT, ILV.Builder, &ILV, &BestVPlan,
+ OrigLoop->getHeader()->getContext());
// 0. Generate SCEV-dependent code into the preheader, including TripCount,
// before making any changes to the CFG.
@@ -10370,16 +10369,9 @@ PreservedAnalyses LoopVectorizePass::run(Function &F,
RemoveRedundantDbgInstrs(&BB);
}
- // We currently do not preserve dominator analyses with outer loop
- // vectorization. Until this is addressed, mark these analyses as preserved
- // only for non-VPlan-native path.
- // TODO: Preserve Dominator analysis for VPlan-native path.
- if (!EnableVPlanNativePath) {
- PA.preserve<DominatorTreeAnalysis>();
- PA.preserve<ScalarEvolutionAnalysis>();
- }
-
PA.preserve<LoopAnalysis>();
+ PA.preserve<DominatorTreeAnalysis>();
+ PA.preserve<ScalarEvolutionAnalysis>();
if (Result.MadeCFGChange) {
// Making CFG changes likely means a loop got vectorized. Indicate that
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index d71d758..bf467eb 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -900,9 +900,9 @@ void VPlan::execute(VPTransformState *State) {
}
State->CFG.DTU.flush();
- // DT is currently updated for non-native path only.
- assert(EnableVPlanNativePath || State->CFG.DTU.getDomTree().verify(
- DominatorTree::VerificationLevel::Fast));
+ assert(State->CFG.DTU.getDomTree().verify(
+ DominatorTree::VerificationLevel::Fast) &&
+ "DT not preserved correctly");
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
diff --git a/llvm/test/Transforms/LoopVectorize/outer_loop_test1.ll b/llvm/test/Transforms/LoopVectorize/outer_loop_test1.ll
index 3b5811d..40d0a51 100644
--- a/llvm/test/Transforms/LoopVectorize/outer_loop_test1.ll
+++ b/llvm/test/Transforms/LoopVectorize/outer_loop_test1.ll
@@ -13,7 +13,7 @@
; }
; }
;
-; RUN: opt -S -passes=loop-vectorize -enable-vplan-native-path -verify-loop-info < %s | FileCheck %s
+; RUN: opt -S -passes=loop-vectorize -enable-vplan-native-path -verify-loop-info -verify-dom-info < %s | FileCheck %s
; CHECK-LABEL: vector.ph:
; CHECK: %[[SplatVal:.*]] = insertelement <4 x i32> poison, i32 %n, i64 0
; CHECK: %[[Splat:.*]] = shufflevector <4 x i32> %[[SplatVal]], <4 x i32> poison, <4 x i32> zeroinitializer