[LV] Don't calculate scalar costs for scalable VFs in setVectorizedCallDecision (#152713)
In setVectorizedCallDecision we attempt to calculate the scalar costs for vectorisation calls, even for scalable VFs where we already know the answer is Invalid. We can avoid doing unnecessary work by skipping this completely for scalable vectors.
This commit is contained in:
parent
694a488708
commit
e172110d12
@ -5832,14 +5832,22 @@ void LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {
|
|||||||
// assumed to be vectors, so we need to extract individual elements from
|
// assumed to be vectors, so we need to extract individual elements from
|
||||||
// there, execute VF scalar calls, and then gather the result into the
|
// there, execute VF scalar calls, and then gather the result into the
|
||||||
// vector return value.
|
// vector return value.
|
||||||
InstructionCost ScalarCallCost =
|
if (VF.isFixed()) {
|
||||||
TTI.getCallInstrCost(ScalarFunc, ScalarRetTy, ScalarTys, CostKind);
|
InstructionCost ScalarCallCost =
|
||||||
|
TTI.getCallInstrCost(ScalarFunc, ScalarRetTy, ScalarTys, CostKind);
|
||||||
|
|
||||||
// Compute costs of unpacking argument values for the scalar calls and
|
// Compute costs of unpacking argument values for the scalar calls and
|
||||||
// packing the return values to a vector.
|
// packing the return values to a vector.
|
||||||
InstructionCost ScalarizationCost = getScalarizationOverhead(CI, VF);
|
InstructionCost ScalarizationCost = getScalarizationOverhead(CI, VF);
|
||||||
|
ScalarCost = ScalarCallCost * VF.getKnownMinValue() + ScalarizationCost;
|
||||||
|
} else {
|
||||||
|
// There is no point attempting to calculate the scalar cost for a
|
||||||
|
// scalable VF as we know it will be Invalid.
|
||||||
|
assert(!getScalarizationOverhead(CI, VF).isValid() &&
|
||||||
|
"Unexpected valid cost for scalarizing scalable vectors");
|
||||||
|
ScalarCost = InstructionCost::getInvalid();
|
||||||
|
}
|
||||||
|
|
||||||
ScalarCost = ScalarCallCost * VF.getKnownMinValue() + ScalarizationCost;
|
|
||||||
// Honor ForcedScalars and UniformAfterVectorization decisions.
|
// Honor ForcedScalars and UniformAfterVectorization decisions.
|
||||||
// TODO: For calls, it might still be more profitable to widen. Use
|
// TODO: For calls, it might still be more profitable to widen. Use
|
||||||
// VPlan-based cost model to compare different options.
|
// VPlan-based cost model to compare different options.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user