[llvm] [VPlan] Compute scalar cost based on VPlan0 instead of legacy CM. (PR #196845)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 07:35:02 PDT 2026


================
@@ -1552,15 +1578,41 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
     return getCostForRecipeWithOpcode(
         getOpcode(),
         vputils::onlyFirstLaneUsed(this) ? ElementCount::getFixed(1) : VF, Ctx);
+  case Instruction::ExtractValue:
+  case Instruction::FNeg:
+  case Instruction::Freeze:
+    if (!VF.isScalar() || !getUnderlyingValue())
+      return 0;
+    return getCostForRecipeWithOpcode(getOpcode(), VF, Ctx);
+  case Instruction::Load:
+  case Instruction::Store:
+    assert(VF.isScalar() && "only scalar VF expected");
+    return getCostForRecipeWithOpcode(getOpcode(), VF, Ctx);
+  case Instruction::Call: {
+    assert(VF.isScalar() && "only scalar VF expected");
+    auto *CalledFn =
+        cast<Function>(getOperand(getNumOperands() - 1)->getLiveInIRValue());
+    SmallVector<const VPValue *> ArgOps(drop_end(operands()));
+    return VPReplicateRecipe::computeCallCost(CalledFn, getScalarType(), ArgOps,
+                                              /*IsSingleScalar=*/true, VF, Ctx);
+  }
+  case VPInstruction::BranchOnCond:
----------------
david-arm wrote:

How do we end up with a `VPInstruction::BranchOnCond` with an underlying value, instead of just a Instruction::Br?

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


More information about the llvm-commits mailing list