Skip to content

Commit de7e3a5

Browse files
committed
[VPlan] Compute cost of scalar (U|S)Div, (U|S)Rem in computeCost (NFCI).
Directly compute the cost of UDiv, SDiv, URem, SRem in VPlan.
1 parent c70b9c8 commit de7e3a5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,9 +3151,23 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
31513151
case Instruction::Xor:
31523152
case Instruction::ICmp:
31533153
case Instruction::FCmp:
3154+
case Instruction::Select:
31543155
return *getCostForRecipeWithOpcode(getOpcode(), ElementCount::getFixed(1),
31553156
Ctx) *
31563157
(isSingleScalar() ? 1 : VF.getFixedValue());
3158+
case Instruction::SDiv:
3159+
case Instruction::UDiv:
3160+
case Instruction::SRem:
3161+
case Instruction::URem: {
3162+
InstructionCost ScalarCost = *getCostForRecipeWithOpcode(
3163+
getOpcode(), ElementCount::getFixed(1), Ctx);
3164+
if (isSingleScalar())
3165+
return ScalarCost;
3166+
3167+
return ScalarCost * VF.getFixedValue() +
3168+
Ctx.getScalarizationOverhead(Ctx.Types.inferScalarType(this),
3169+
to_vector(operands()), VF);
3170+
}
31573171
case Instruction::Load:
31583172
case Instruction::Store: {
31593173
if (isSingleScalar()) {

0 commit comments

Comments
 (0)