[llvm] [LV] Fix crash when forced UserVF and EpilogueVF are ignored (PR #218282)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 23 12:44:34 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-vectorizers
@llvm/pr-subscribers-llvm-transforms
Author: Hassnaa Hamdi (hassnaaHamdi)
<details>
<summary>Changes</summary>
`computeBestVF()` assumes/asserts that there should be only 2 vplans as
long as there is a vplan for `UserVF` and when `EpilogueVF` is forced.
It doesn't consider the case when those VFs are ignored because of invalid costs.
This patch removes the assert and add a check for the vplan size.
Reproducer: https://godbolt.org/z/TMzbbTj7P
---
Full diff: https://github.com/llvm/llvm-project/pull/218282.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+1-2)
- (modified) llvm/test/Transforms/LoopVectorize/AArch64/scalable-alloca.ll (+1-1)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index bf0bb98eb75b8..c3e39f5adf175 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -5820,8 +5820,7 @@ LoopVectorizationPlanner::computeBestVF() {
return {VectorizationFactor(FirstPlan.getSingleVF(), 0, 0), &FirstPlan};
}
- if (hasPlanWithVF(UserVF) && hasForcedEpilogueVF()) {
- assert(VPlans.size() == 2 && "Must have exactly 2 VPlans built");
+ if (hasPlanWithVF(UserVF) && hasForcedEpilogueVF() && VPlans.size() == 2) {
assert(VPlans[0]->getSingleVF() == UserVF &&
"expected second plan to be for the forced UserVF");
assert(VPlans[1]->getSingleVF() == EpilogueVectorizationForceVF &&
diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/scalable-alloca.ll b/llvm/test/Transforms/LoopVectorize/AArch64/scalable-alloca.ll
index 73384c7d383ba..336c9f876bec9 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/scalable-alloca.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/scalable-alloca.ll
@@ -1,4 +1,4 @@
-; RUN: opt -S -passes=loop-vectorize -mattr=+sve -mtriple aarch64-unknown-linux-gnu -force-vector-width=2 -pass-remarks-analysis=loop-vectorize -pass-remarks-missed=loop-vectorize < %s 2>%t | FileCheck %s
+; RUN: opt -S -passes=loop-vectorize -mattr=+sve -mtriple aarch64-unknown-linux-gnu -force-vector-width=2 -epilogue-vectorization-force-VF=2 -pass-remarks-analysis=loop-vectorize -pass-remarks-missed=loop-vectorize < %s 2>%t | FileCheck %s
; RUN: FileCheck %s --check-prefix=CHECK-REMARKS < %t
; CHECK-REMARKS: UserVF ignored because of invalid costs.
``````````
</details>
https://github.com/llvm/llvm-project/pull/218282
More information about the llvm-commits
mailing list