[llvm] [VPlan] Support pointer min/max bounds in VPlan memory runtime checks. (PR #225828)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 05:39:16 PDT 2026
================
@@ -1102,9 +1102,24 @@ 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()) {
+ Result = Builder.createScalarIntrinsic(IntrinsicID, {Result, Op},
+ ResultTy, DL);
+ continue;
+ }
+ // 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();
+ if (MDNode *MD =
+ getExplicitlyUnknownBranchWeightsIfProfiled(F, "scev-expander"))
+ Sel->setMetadata(LLVMContext::MD_prof, MD);
+ Result = Sel;
----------------
fhahn wrote:
Updated (modulo `getIRFunction` which does not exist yet), thanks
https://github.com/llvm/llvm-project/pull/225828
More information about the llvm-commits
mailing list