[llvm] [LoopVectorize] Call verifyFunction behind EXPENSIVE_CHECKS (PR #216448)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 19:46:48 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Fangrui Song (MaskRay)

<details>
<summary>Changes</summary>

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.


---
Full diff: https://github.com/llvm/llvm-project/pull/216448.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+2) 


``````````diff
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;
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/216448


More information about the llvm-commits mailing list