[llvm] [AArch64][CostModel] Improve cost estimate of scalarizing a vector di… (PR #118055)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 8 14:55:47 PST 2025
davemgreen wrote:
I happened to be looking at urem costs recently - not exactly related to this but led to a similar area. I was only going to update the urem by constant values but the sdiv costs are similar.
I'm not sure this needs to alter the SLP vectorizer for the example tests. So long as all the second operands are constant or power-of-two it should be expanding to a not use a div (and not scalarize). I think we can update this bit of code:
https://github.com/llvm/llvm-project/blob/2b26ee6e790574e05c3c9a562bc37897daf0f384/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp#L3495
- It probably should not matter that the constant is uniform.
- It should handle negative-powers of 2 too for sdiv.
- The cost should use Add + ICmp + Sel + AShr. (The sel goes through the wrong method).
- We can maybe add SVE asrd but that can happen in a later patch.
- I believe vector types have the same expansion and costs as scalars.
- srem has a similar cost to sdiv for these values, but that should probably be added later too, as there is more than just power-2 values.
https://github.com/llvm/llvm-project/pull/118055
More information about the llvm-commits
mailing list