[llvm] [LoopVectorize] Call verifyFunction behind EXPENSIVE_CHECKS (PR #216448)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 14 19:46:09 PDT 2026
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/216448
processLoop verifies the whole function once per vectorized loop, making
LoopVectorize quadratic in the number of loops per function on assertion
builds. In an `opt -O3` run the verifier accounts for 59% of the
instructions for a function with 800 vectorizable loops, and 5.6% for
SingleSource/Benchmarks/Linpack/linpack-pc.c.
The call was added under DEBUG() in 2012 and became unconditional on
assertion builds in c9f63297e24a. 0aa75fb12faa guarded the identical
SLPVectorizer call to fix #48033.
>From a9441a2769a7e52ff179b18744e4840888e7d3ec Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Fri, 14 Aug 2026 19:41:11 -0700
Subject: [PATCH] [LoopVectorize] Call verifyFunction behind EXPENSIVE_CHECKS
processLoop verifies the whole function once per vectorized loop, making
LoopVectorize quadratic in the number of loops per function on assertion
builds. In an `opt -O3` run the verifier accounts for 59% of the
instructions for a function with 800 vectorizable loops, and 5.6% for
SingleSource/Benchmarks/Linpack/linpack-pc.c.
The call was added under DEBUG() in 2012 and became unconditional on
assertion builds in c9f63297e24a. 0aa75fb12faa guarded the identical
SLPVectorizer call to fix #48033.
---
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index c12a4f562f600..95b57c48eaa07 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8380,7 +8380,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
assert(DT->verify(DominatorTree::VerificationLevel::Fast) &&
"DT not preserved correctly");
+#ifdef EXPENSIVE_CHECKS
assert(!verifyFunction(*F, &dbgs()));
+#endif
return true;
}
More information about the llvm-commits
mailing list