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

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 15:47:52 PDT 2026


================
@@ -1541,13 +1494,55 @@ void VPlanTransforms::attachCheckBlock(VPlan &Plan, Value *Cond,
   attachVPCheckBlock(Plan, CondVPV, CheckBlockVPBB, AddBranchWeights);
 }
 
+void VPlanTransforms::addMemoryRuntimeChecks(
+    VPlan &Plan, ArrayRef<RuntimePointerCheck> Checks, ScalarEvolution &SE,
+    DebugLoc DL, bool AddBranchWeights) {
+  assert(!Checks.empty() && "no checks to replace the pre-built block with");
+
+  auto *MemCheckVPBB = Plan.createVPBasicBlock("vector.memcheck");
+  VPBuilder Builder(MemCheckVPBB);
+  insertCheckBlockBeforeVectorLoop(Plan, MemCheckVPBB);
+  VPSCEVExpander Expander(Builder, SE, DL);
+
+  // Expand each group's bounds once and up front.
+  SmallDenseMap<const RuntimeCheckingPtrGroup *,
+                std::pair<VPValue *, VPValue *>>
+      GroupToBounds;
+  for (const auto &[A, B] : Checks)
+    for (const RuntimeCheckingPtrGroup *CG : {A, B}) {
----------------
artagnon wrote:

```suggestion
  for (const auto &Check : Checks)
    for (const RuntimeCheckingPtrGroup *CG : Check) {
```

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


More information about the llvm-commits mailing list