[llvm] [VPlan] Model first memory runtime checks as VPlan recipes. (PR #221483)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 06:56:00 PDT 2026


================
@@ -1821,8 +1811,33 @@ class GeneratedRTChecks {
   }
 
   /// Return true if any runtime checks have been added
-  bool hasChecks() const {
-    return getSCEVChecks().first || getMemRuntimeChecks().first;
+  bool hasChecks() const { return getSCEVChecks().first || HasMemChecks; }
+
+  /// Drop the pre-built memory check block in favour of VPlan recipes.
+  /// TODO: Remove once the checks can be costed in VPlan, before VF selection.
----------------
david-arm wrote:

OK, the reason I'm asking is because presumably the main benefit of this PR is the ability to reason about a more accurate cost of runtime memory checks, since instcombine will likely perform the same simplifications anyway. At the moment I think we add minimum iteration count checks based on what looks like conservative costs (given this PR shows how vplan transforms have simplified the checks). Also, it would mean in future we could rewrite the algorithm for runtime memory checks so that we don't use a crude threshold for the number of runtime checks as reported by LAA, but instead move towards comparing the actual cost with a threshold. We might still need a threshold to limit compile time so that we don't speculatively create vplans in pathological cases.

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


More information about the llvm-commits mailing list