[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


================
@@ -1077,9 +1078,31 @@ VPValue *VPSCEVExpander::expand(const SCEV *S) {
       Ops.push_back(OpV);
     }
     VPValue *Result = Ops.front();
-    for (VPValue *Op : drop_begin(Ops))
-      Result = Builder.createScalarIntrinsic(IntrinsicID, {Result, Op},
-                                             ResultTy, DL);
+    for (VPValue *Op : drop_begin(Ops)) {
+      if (ResultTy->isPointerTy()) {
+        // The min/max intrinsics don't support pointer operands, so expand
+        // pointer-typed min/max as cmp + select, matching SCEVExpander.
+        VPValue *Cmp = Builder.createICmp(
+            MinMaxIntrinsic::getPredicate(IntrinsicID), Result, Op, DL);
+        VPInstruction *Sel = Builder.createSelect(Cmp, Result, Op, DL);
+        Function *F =
+            Builder.getPlan().getScalarHeader()->getIRBasicBlock()->getParent();
----------------
artagnon wrote:

```suggestion
        Function *F =
            Builder.getPlan().getIRFunction();
```

Once the const-fold-alm patch lands? Alternatively, just duplicate it here, and the conflicts will be auto-resolved?

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


More information about the llvm-commits mailing list