[llvm] [VPlan] Factor out logic to common compute costs to helper (NFCI). (PR #153361)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 18 03:53:01 PDT 2025


================
@@ -940,28 +940,88 @@ Value *VPInstruction::generate(VPTransformState &State) {
   }
 }
 
+std::optional<InstructionCost>
+VPRecipeWithIRFlags::getCommonCost(unsigned Opcode, ElementCount VF,
+                                   VPCostContext &Ctx, bool IsVector) const {
+  Type *ScalarTy = Ctx.Types.inferScalarType(this);
+  Type *ResultTy = IsVector ? toVectorTy(ScalarTy, VF) : ScalarTy;
+  switch (Opcode) {
+  case Instruction::FNeg:
+    return Ctx.TTI.getArithmeticInstrCost(
+        Opcode, ResultTy, Ctx.CostKind,
+        {TargetTransformInfo::OK_AnyValue, TargetTransformInfo::OP_None},
+        {TargetTransformInfo::OK_AnyValue, TargetTransformInfo::OP_None});
----------------
fhahn wrote:

Yep, updated, thanks

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


More information about the llvm-commits mailing list