[llvm] [LV] Separate runtime check cost from total overhead in profitability check (PR #176754)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 21 02:48:04 PST 2026
================
@@ -9174,21 +9174,22 @@ static bool isOutsideLoopWorkProfitable(GeneratedRTChecks &Checks,
VPCostContext &CostCtx, VPlan &Plan,
ScalarEpilogueLowering SEL,
std::optional<unsigned> VScale) {
- InstructionCost TotalCost = Checks.getCost();
- if (!TotalCost.isValid())
+ InstructionCost RtCost = Checks.getCost();
+ if (!RtCost.isValid())
return false;
+ InstructionCost OverheadCost = RtCost;
// Add on the cost of any work required in the vector early exit block, if
// one exists.
- TotalCost += calculateEarlyExitCost(CostCtx, Plan, VF.Width);
+ OverheadCost += calculateEarlyExitCost(CostCtx, Plan, VF.Width);
- TotalCost += Plan.getMiddleBlock()->cost(VF.Width, CostCtx);
+ OverheadCost += Plan.getMiddleBlock()->cost(VF.Width, CostCtx);
// When interleaving only scalar and vector cost will be equal, which in turn
// would lead to a divide by 0. Fall back to hard threshold.
if (VF.Width.isScalar()) {
// TODO: Should we rename VectorizeMemoryCheckThreshold?
- if (TotalCost > VectorizeMemoryCheckThreshold) {
+ if (OverheadCost > VectorizeMemoryCheckThreshold) {
----------------
lukel97 wrote:
VectorizeMemoryCheckThreshold does seem weird. Could we reuse the MinTC2 check instead for interleaving only?
https://github.com/llvm/llvm-project/pull/176754
More information about the llvm-commits
mailing list