[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
Mon Jun 22 03:58:20 PDT 2026


================
@@ -1879,10 +1928,8 @@ void VPInstructionWithType::execute(VPTransformState &State) {
 
 InstructionCost VPInstructionWithType::computeCost(ElementCount VF,
                                                    VPCostContext &Ctx) const {
-  // NOTE: At the moment it seems only possible to expose this path for
-  // the trunc, zext and sext opcodes. However, isScalarCast also covers
-  // int<>fp conversions, bitcasts, ptr<>int conversions, etc.
-  if (Instruction::isCast(getOpcode()))
+  // Always compute costs for scalar VF and casts.
+  if (VF.isScalar() || Instruction::isCast(getOpcode()))
----------------
david-arm wrote:

Is the `Instruction::isCast` cast check actually needed now? I don't know if we'd ever create a cast instruction with vector types.

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


More information about the llvm-commits mailing list