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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 06:50:30 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;
----------------
fhahn wrote:

I was able to only make this work half-the-way. I still kept the checks checks up-front, but included in `GeneratedRTChecks::tryToAddMemRuntimeChecksToVPlan`

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


More information about the llvm-commits mailing list