[llvm] [LV] Add initial costs for VPInstructionWithType::computeCost (PR #198291)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 7 12:43:52 PDT 2026


================
@@ -1604,6 +1625,31 @@ void VPInstruction::printRecipe(raw_ostream &O, const Twine &Indent,
 }
 #endif
 
+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 (isScalarCast())
+    return getCostForRecipeWithOpcode(getOpcode(), ElementCount::getFixed(1),
+                                      Ctx);
+
+  switch (getOpcode()) {
+  case VPInstruction::VScale: {
----------------
fhahn wrote:

Yep, I think it would be good to limit `getCostForRecipeWithOpcode` to just Instruction opcodes, `VPInstruction::VScale` should only be possible in this path here

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


More information about the llvm-commits mailing list