[llvm] [LV] Tidy up early bail outs related to runtime checks (PR #228077)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 06:42:53 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-vectorizers
Author: David Sherwood (david-arm)
<details>
<summary>Changes</summary>
There was no debug or error reporting when bailing out due to proving at compile time that we will fail the SCEV checks. I've added debug and a report for this. Also, the early bail out for runtime memory checks has no corresponding test and I cannot find any test that breaks when I remove it. I also cannot expose this code path when building the LLVM test suite, so I've removed it as dead code.
---
Full diff: https://github.com/llvm/llvm-project/pull/228077.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+6-4)
- (modified) llvm/test/Transforms/LoopVectorize/AArch64/runtime-check-size-based-threshold.ll (+5-1)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 45edf702d7092..c6edd933b17ff 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7953,11 +7953,13 @@ bool LoopVectorizePass::processLoop(Loop *L) {
// fail. In that case, the vector loop would never execute.
using namespace llvm::PatternMatch;
if (Checks.getSCEVChecks().first &&
- match(Checks.getSCEVChecks().first, m_One()))
- return false;
- if (Checks.getMemRuntimeChecks().first &&
- match(Checks.getMemRuntimeChecks().first, m_One()))
+ match(Checks.getSCEVChecks().first, m_One())) {
+ reportVectorizationFailure(
+ "runtime checks are known to fail, so we will never enter the "
+ "vector loop",
+ "RuntimeChecksNeverEnterVectorLoop", ORE, L);
return false;
+ }
}
// Check if it is profitable to vectorize with runtime checks.
diff --git a/llvm/test/Transforms/LoopVectorize/AArch64/runtime-check-size-based-threshold.ll b/llvm/test/Transforms/LoopVectorize/AArch64/runtime-check-size-based-threshold.ll
index 9ded4ccc2822c..df4750abd6b4a 100644
--- a/llvm/test/Transforms/LoopVectorize/AArch64/runtime-check-size-based-threshold.ll
+++ b/llvm/test/Transforms/LoopVectorize/AArch64/runtime-check-size-based-threshold.ll
@@ -1,7 +1,9 @@
; RUN: opt -passes=loop-vectorize -mtriple=arm64-apple-iphoneos -vectorizer-min-trip-count=8 \
; RUN: -enable-epilogue-vectorization=false -S %s | FileCheck --check-prefixes=CHECK,DEFAULT %s
; RUN: opt -passes=loop-vectorize -mtriple=arm64-apple-iphoneos -vectorizer-min-trip-count=8 \
-; RUN: -enable-epilogue-vectorization=false -vectorize-memory-check-threshold=1 -S %s | FileCheck --check-prefixes=CHECK,THRESHOLD %s
+; RUN: -enable-epilogue-vectorization=false -vectorize-memory-check-threshold=1 -S %s \
+; RUN: -debug-only=loop-vectorize 2> %t | FileCheck --check-prefixes=CHECK,THRESHOLD %s
+; RUN: cat %t | FileCheck --check-prefix=DEBUG %s
; Tests for loops with large numbers of runtime checks. Check that loops are
; vectorized, if the loop trip counts are large and the impact of the runtime
@@ -12,6 +14,8 @@
; CHECK-LABEL: define {{.*}} @test_tc_too_small
; CHECK-NOT: vector.memcheck
; CHECK-NOT: vector.body
+; DEBUG-LABEL: Checking a loop in 'test_tc_too_small'
+; DEBUG: LV: Not vectorizing: runtime checks are known to fail, so we will never enter the vector loop.
define void @test_tc_too_small(ptr %ptr.1, ptr %ptr.2, ptr %ptr.3, ptr %ptr.4, i64 %off.1, i64 %off.2) {
entry:
br label %loop
``````````
</details>
https://github.com/llvm/llvm-project/pull/228077
More information about the llvm-commits
mailing list