Skip to content

Commit e12bd04

Browse files
committed
!fixup, Add Mul cost to prevent FMuladd Reduction cost misaligned.
1 parent 0d7b7f3 commit e12bd04

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -721,19 +721,25 @@ Value *VPInstruction::generate(VPTransformState &State) {
721721
InstructionCost VPInstruction::computeCost(ElementCount VF,
722722
VPCostContext &Ctx) const {
723723
if (Instruction::isBinaryOp(getOpcode())) {
724+
725+
Type *ResTy = Ctx.Types.inferScalarType(this);
726+
if (!vputils::onlyFirstLaneUsed(this))
727+
ResTy = toVectorTy(ResTy, VF);
728+
724729
if (!getUnderlyingValue()) {
725-
// TODO: Compute cost for VPInstructions without underlying values once
726-
// the legacy cost model has been retired.
727-
return 0;
730+
switch (getOpcode()) {
731+
case Instruction::FMul:
732+
return Ctx.TTI.getArithmeticInstrCost(getOpcode(), ResTy, Ctx.CostKind);
733+
default:
734+
// TODO: Compute cost for VPInstructions without underlying values once
735+
// the legacy cost model has been retired.
736+
return 0;
737+
}
728738
}
729739

730740
assert(!doesGeneratePerAllLanes() &&
731741
"Should only generate a vector value or single scalar, not scalars "
732742
"for all lanes.");
733-
Type *ResTy = Ctx.Types.inferScalarType(this);
734-
if (!vputils::onlyFirstLaneUsed(this))
735-
ResTy = toVectorTy(ResTy, VF);
736-
737743
return Ctx.TTI.getArithmeticInstrCost(getOpcode(), ResTy, Ctx.CostKind);
738744
}
739745

0 commit comments

Comments
 (0)