[llvm] [LAA] Add stencil group merging to reduce runtime pointer checks (PR #187252)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 09:48:52 PDT 2026


================
@@ -100,6 +102,36 @@ static cl::opt<unsigned> MemoryCheckMergeThreshold(
              "runtime memory checks. (default = 100)"),
     cl::init(100));
 
+enum class StencilMergePolicy { Off, Auto, Force };
+
+static cl::opt<StencilMergePolicy> StencilMerge(
+    "stencil-runtime-check-merge", cl::Hidden,
+    cl::desc("Control stencil-pattern merging of runtime memory checks"),
+    cl::init(StencilMergePolicy::Off),
+    cl::values(
+        clEnumValN(StencilMergePolicy::Off, "off",
+                   "Disable stencil merge (default)"),
+        clEnumValN(StencilMergePolicy::Auto, "auto",
+                   "Enable stencil merge when runtime check count exceeds "
+                   "the threshold"),
+        clEnumValN(StencilMergePolicy::Force, "force",
+                   "Always attempt stencil merge regardless of check "
+                   "count")));
+
+static cl::opt<unsigned> StencilMergeCheckThreshold(
----------------
david-arm wrote:

Given this parameter is supposed to match the exact same parameter that the vectoriser uses for non-stencil runtime checks (`VectorizeMemoryCheckThreshold`), we will have to keep the two in sync if one changes. I think it's worth adding a comment on both `StencilMergeCheckThreshold` and `VectorizeMemoryCheckThreshold` that the two should be kept in sync.

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


More information about the llvm-commits mailing list