Skip to content

Commit e37c2ad

Browse files
committed
!fixup update after rebase.
1 parent 9a955b1 commit e37c2ad

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -713,14 +713,34 @@ Value *VPInstruction::generate(VPTransformState &State) {
713713

714714
InstructionCost VPInstruction::computeCost(ElementCount VF,
715715
VPCostContext &Ctx) const {
716+
if (Instruction::isBinaryOp(getOpcode())) {
717+
if (!getUnderlyingValue()) {
718+
// TODO: Compute cost for VPInstructions without underlying values once
719+
// the legacy cost model has been retired.
720+
return 0;
721+
}
722+
723+
assert(!doesGeneratePerAllLanes() &&
724+
"Should only generate a vector value or single scalar, not scalars "
725+
"for all lanes.");
726+
Type *ResTy = Ctx.Types.inferScalarType(this);
727+
if (!vputils::onlyFirstLaneUsed(this))
728+
ResTy = toVectorTy(ResTy, VF);
729+
730+
return Ctx.TTI.getArithmeticInstrCost(getOpcode(), ResTy, Ctx.CostKind);
731+
}
732+
716733
switch (getOpcode()) {
717734
case VPInstruction::AnyOf: {
718735
auto *VecTy = toVectorTy(Ctx.Types.inferScalarType(this), VF);
719736
return Ctx.TTI.getArithmeticReductionCost(
720737
Instruction::Or, cast<VectorType>(VecTy), std::nullopt, Ctx.CostKind);
721738
}
722739
default:
723-
// TODO: Fill out other opcodes!
740+
// TODO: Compute cost other VPInstructions once the legacy cost model has
741+
// been retired.
742+
assert(!getUnderlyingValue() &&
743+
"unexpected VPInstruction witht underlying value");
724744
return 0;
725745
}
726746
}
@@ -782,32 +802,6 @@ void VPInstruction::execute(VPTransformState &State) {
782802
/*IsScalar*/ GeneratesPerFirstLaneOnly);
783803
}
784804

785-
InstructionCost VPInstruction::computeCost(ElementCount VF,
786-
VPCostContext &Ctx) const {
787-
if (Instruction::isBinaryOp(getOpcode())) {
788-
if (!getUnderlyingValue()) {
789-
// TODO: Compute cost for VPInstructions without underlying values once
790-
// the legacy cost model has been retired.
791-
return 0;
792-
}
793-
794-
assert(!doesGeneratePerAllLanes() &&
795-
"Should only generate a vector value or single scalar, not scalars "
796-
"for all lanes.");
797-
Type *ResTy = Ctx.Types.inferScalarType(this);
798-
if (!vputils::onlyFirstLaneUsed(this))
799-
ResTy = toVectorTy(ResTy, VF);
800-
801-
return Ctx.TTI.getArithmeticInstrCost(getOpcode(), ResTy, Ctx.CostKind);
802-
}
803-
804-
// TODO: Compute cost other VPInstructions once the legacy cost model has
805-
// been retired.
806-
assert(!getUnderlyingValue() &&
807-
"unexpected VPInstruction witht underlying value");
808-
return 0;
809-
}
810-
811805
bool VPInstruction::opcodeMayReadOrWriteFromMemory() const {
812806
if (Instruction::isBinaryOp(getOpcode()))
813807
return false;

0 commit comments

Comments
 (0)