[llvm] [VPlan] Consider address computation cost in VPInterleaveRecipe. (PR #148808)
Ricardo Jesus via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 15 04:55:10 PDT 2025
================
@@ -3666,6 +3666,9 @@ InstructionCost VPInterleaveRecipe::computeCost(ElementCount VF,
InsertPos->getOpcode(), WideVecTy, IG->getFactor(), Indices,
IG->getAlign(), AS, Ctx.CostKind, getMask(), NeedsMaskForGaps);
+ // Add the address computation cost.
+ Cost += Ctx.TTI.getAddressComputationCost(WideVecTy);
----------------
rj-jesus wrote:
> The main problem that I see here is that there is now an inconsistency between this and LoopVectorizationCostModel::getInterleaveGroupCost
You're right, thanks for pointing this out! I'll update the patch shortly (I had initially also updated `LoopVectorizationCostModel::getInterleaveGroupCost`, but I wasn't aware of the first point you raised, and since the change to `getInterleaveGroupCost` didn't affect the motivating example, I eventually reverted it before opening the PR).
> I think by itself the idea of this patch seems reasonable, but it's worth pointing out that even if we make better vectorisation choices the outcome is still very fragile.
I agree, and I had planned to look at the code we are generating for the interleaved version separately. I just thought this seemed reasonable on its own to make the comparison with the scalar version a bit fairer, and it solves the problem for the time being.
For what it's worth, prior to #106431 we used to choose the scalar version because the plan generated happened to have one extra instruction that nudged the decision to prefer the scalar version.
https://github.com/llvm/llvm-project/pull/148808
More information about the llvm-commits
mailing list