[llvm] [AArch64][CostModel] Consider the cost of const vector (PR #117539)

David Green via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 2 11:25:04 PST 2024


davemgreen wrote:

Hi. Here are some random thoughts about costing constant, in no particular order.
 - I thought this was already done for X86, but it is only in specific places, mostly from direct stores of constants. https://reviews.llvm.org/D126885
 - The cost of constants is often (but not always) 0.
 -- If the constant is shared then the cost 1/number-of-uses. There was a recent regression from this in https://github.com/llvm/llvm-project/issues/111126.
 -- If the constant is in a loop it can usually be hoisted. So cost is 1/num-of-iterations.
 -- If the constant can be folded into the instruction, especially for scalars the cost can be free. In the places where this is used it goes via getIntImmCost.
 - This function looks like it is not the cost of a vector constant, but the relative cost of vector vs the scalar equivalents. Some of the scalars could be loaded from memory too.
 - 4 seems like a very high cost for a constant-pool load, when measured as a throughput. I would expect it to be 1ish.
 - This looks like it tries to discourage more SLP vectorization, which is probably not a bad thing in some cases.
 - Including the costs somehow is probably a good idea, but there are reasons why this has not been done before. We should try and come up with a consistent way of doing it, ideally.

https://github.com/llvm/llvm-project/pull/117539


More information about the llvm-commits mailing list