[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


================
@@ -1357,6 +1376,13 @@ InstructionCost VPRecipeWithIRFlags::getCostForRecipeWithOpcode(
 
 InstructionCost VPInstruction::computeCost(ElementCount VF,
                                            VPCostContext &Ctx) const {
+  // A scalar cost is only computed for VPlan0, which has no vector-only
+  // opcodes.
+  assert(!(VF.isScalar() &&
+           (isVectorToScalar() ||
+            getOpcode() == VPInstruction::FirstOrderRecurrenceSplice)) &&
----------------
david-arm wrote:

I'm surprised we don't already have a utility function for this. Is there any value in creating a `isVectorOnly` utility routine? Not sure if it would be useful elsewhere though.

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


More information about the llvm-commits mailing list