[llvm] 4718b40 - [LV] Invalidate disposition of SCEV values after loop vectorization (#69230)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 16 12:49:44 PDT 2023
Author: Yingwei Zheng
Date: 2023-10-17T03:49:39+08:00
New Revision: 4718b4011f1d3038c73e2594e4651243f4a221e5
URL: https://github.com/llvm/llvm-project/commit/4718b4011f1d3038c73e2594e4651243f4a221e5
DIFF: https://github.com/llvm/llvm-project/commit/4718b4011f1d3038c73e2594e4651243f4a221e5.diff
LOG: [LV] Invalidate disposition of SCEV values after loop vectorization (#69230)
This PR fixes the assertion failure of `SE.verify()` after loop vectorization.
Added:
llvm/test/Transforms/LoopVectorize/scev-invalidation.ll
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 2ca7e75f97f0f02..aa435b0d47aa599 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3543,6 +3543,7 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State,
// Forget the original basic block.
PSE.getSE()->forgetLoop(OrigLoop);
+ PSE.getSE()->forgetBlockAndLoopDispositions();
// After vectorization, the exit blocks of the original loop will have
// additional predecessors. Invalidate SCEVs for the exit phis in case SE
@@ -10339,8 +10340,14 @@ LoopVectorizeResult LoopVectorizePass::runImpl(
Changed |= CFGChanged |= processLoop(L);
- if (Changed)
+ if (Changed) {
LAIs->clear();
+
+#ifndef NDEBUG
+ if (VerifySCEV)
+ SE->verify();
+#endif
+ }
}
// Process each loop nest in the function.
@@ -10388,10 +10395,6 @@ PreservedAnalyses LoopVectorizePass::run(Function &F,
PA.preserve<LoopAnalysis>();
PA.preserve<DominatorTreeAnalysis>();
PA.preserve<ScalarEvolutionAnalysis>();
-
-#ifdef EXPENSIVE_CHECKS
- SE.verify();
-#endif
}
if (Result.MadeCFGChange) {
diff --git a/llvm/test/Transforms/LoopVectorize/scev-invalidation.ll b/llvm/test/Transforms/LoopVectorize/scev-invalidation.ll
new file mode 100644
index 000000000000000..08163293c14e85e
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/scev-invalidation.ll
@@ -0,0 +1,22 @@
+; RUN: opt < %s -passes="require<scalar-evolution>,print<scalar-evolution>,loop-vectorize" --verify-scev -force-vector-interleave=2 -force-vector-width=8 -S | FileCheck %s
+
+; CHECK-LABEL: @main(
+; CHECK: vector.body
+define i32 @main(i32 %.pre) {
+entry:
+ br label %for.body
+
+for.body:
+ %g.019 = phi i16 [ 0, %entry ], [ %dec7, %for.body ]
+ %and = and i32 %.pre, 40
+ %0 = sub i32 0, %and
+ %dec7 = add i16 %g.019, 1
+ %cmp.not = icmp eq i16 %dec7, 0
+ br i1 %cmp.not, label %for.inc16, label %for.body
+
+for.inc16:
+ %1 = phi i32 [ %inc, %for.inc16 ], [ 0, %for.body ]
+ %inc = add i32 %1, 1
+ %add12 = add i32 %0, %1
+ br label %for.inc16
+}
More information about the llvm-commits
mailing list