[llvm] [VPlan] Compute cost for binary op VPInstruction with underlying values. (PR #125434)
Hassnaa Hamdi via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 5 07:45:47 PST 2025
================
@@ -768,6 +768,32 @@ void VPInstruction::execute(VPTransformState &State) {
/*IsScalar*/ GeneratesPerFirstLaneOnly);
}
+InstructionCost VPInstruction::computeCost(ElementCount VF,
+ VPCostContext &Ctx) const {
+ if (Instruction::isBinaryOp(getOpcode())) {
+ if (!getUnderlyingValue()) {
+ // TODO: Compute cost for VPInstructions without underlying values once
+ // the legacy cost model has been retired.
+ return 0;
+ }
+
+ assert(!doesGeneratePerAllLanes() &&
+ "Should only generate a vector value or single scalar, not scalars "
+ "for all lanes.");
+ Type *ResTy = Ctx.Types.inferScalarType(this);
+ if (!vputils::onlyFirstLaneUsed(this))
+ ResTy = toVectorTy(ResTy, VF);
+
+ return Ctx.TTI.getArithmeticInstrCost(getOpcode(), ResTy, Ctx.CostKind);
+ }
+
+ // TODO: Compute cost other VPInstructions once the legacy cost model has
+ // been retired.
+ assert(!getUnderlyingValue() &&
----------------
hassnaaHamdi wrote:
Thanks for the clarification.
https://github.com/llvm/llvm-project/pull/125434
More information about the llvm-commits
mailing list