[llvm] [VPlan] Consider address computation cost in VPInterleaveRecipe. (PR #148808)
Ricardo Jesus via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 7 06:35:49 PDT 2025
rj-jesus wrote:
> Could you first add a few lit test cases for interleaved accesses with factor 5 as a pre-commit? Also, I suggest making the change in getInterleavedMemoryOpCost, which might be a more appropriate place.
Hi @Mel-Chen, Thanks for the suggestion! Do you mean a test like those in `Transforms/LoopVectorize/AArch64/interleaved_cost.ll` such as:
```
%float.5 = type {float, float, float, float, float}
define void @float_factor_5(ptr %data, i64 %n) {
entry:
br label %for.body
for.body:
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
%gep0 = getelementptr inbounds %float.5, ptr %data, i64 %i, i32 0
%gep1 = getelementptr inbounds %float.5, ptr %data, i64 %i, i32 1
%gep2 = getelementptr inbounds %float.5, ptr %data, i64 %i, i32 2
%gep3 = getelementptr inbounds %float.5, ptr %data, i64 %i, i32 3
%gep4 = getelementptr inbounds %float.5, ptr %data, i64 %i, i32 4
%val0 = load float, ptr %gep0, align 4
%val1 = load float, ptr %gep1, align 4
%val2 = load float, ptr %gep2, align 4
%val3 = load float, ptr %gep3, align 4
%val4 = load float, ptr %gep4, align 4
store float %val0, ptr %gep0, align 4
store float %val1, ptr %gep1, align 4
store float %val2, ptr %gep2, align 4
store float %val3, ptr %gep3, align 4
store float %val4, ptr %gep4, align 4
%i.next = add nuw nsw i64 %i, 1
%cond = icmp slt i64 %i.next, %n
br i1 %cond, label %for.body, label %for.end
for.end:
ret void
}
```
Or are you suggesting a more complex test, similar to the loop in the PR description (https://godbolt.org/z/o1fGfj6j7)?
As for making the change in `getInterleavedMemoryOpCost`, I'm happy to move it there if others agree, but it seems that most uses of `getAddressComputationCost` are in LoopVectorize (e.g. [`getUniformMemOpCost`](https://github.com/llvm/llvm-project/blob/900d20d0dc7b228cba9df98ed3ec713098c79342/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp#L5351), [`getGatherScatterCost`](https://github.com/llvm/llvm-project/blob/900d20d0dc7b228cba9df98ed3ec713098c79342/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp#L5381), and [`getMemoryInstructionCost`](https://github.com/llvm/llvm-project/blob/900d20d0dc7b228cba9df98ed3ec713098c79342/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp#L5620)) and VPlanRecipes ([`VPWidenMemoryRecipe::computeCost`](https://github.com/llvm/llvm-project/blob/900d20d0dc7b228cba9df98ed3ec713098c79342/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp#L3102)). What do you think?
https://github.com/llvm/llvm-project/pull/148808
More information about the llvm-commits
mailing list