[llvm] [LV] Add on extra cost for scalarising math calls in vector loops (PR #158611)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 16 02:27:45 PDT 2025
================
@@ -1004,10 +1016,44 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
}
break;
}
+ case Intrinsic::asin:
+ case Intrinsic::acos:
+ case Intrinsic::atan:
+ case Intrinsic::atan2:
+ case Intrinsic::sin:
+ case Intrinsic::cos:
+ case Intrinsic::tan:
+ case Intrinsic::sinh:
+ case Intrinsic::cosh:
+ case Intrinsic::tanh:
+ case Intrinsic::pow:
+ case Intrinsic::exp:
+ case Intrinsic::exp10:
+ case Intrinsic::exp2:
+ case Intrinsic::log:
+ case Intrinsic::log10:
+ case Intrinsic::log2: {
+ if (auto *FixedVTy = dyn_cast<FixedVectorType>(RetTy))
+ BaseCost = getCallScalarizationCost(FixedVTy->getElementCount());
+ break;
----------------
david-arm wrote:
We could add it to the cost of scalarisation of the return type, but I didn't do this for two reasons:
1. Does the return type guarantee to represent the VF of the loop in all cases? Probably for math calls this is true as we'll always return a value.
2. We'd also have to pass in an extra Instruction pointer to provide context so that we only increase the cost for calls. It felt a bit awkward expanding the interface for this one case.
https://github.com/llvm/llvm-project/pull/158611
More information about the llvm-commits
mailing list