[llvm] [AArch64] Fix cost of vector shifts with non-uniform constant amounts (PR #214206)

David Green via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 06:33:01 PDT 2026


https://github.com/davemgreen approved this pull request.

> Hi, I think it's difficult to make it accurate for all cases, for example here are different scenarios, each emits different number of `ldr/adrp` https://godbolt.org/z/x4PMc9shW

Yeah the costing of constants it really a higher level problem that can't be fixed at the instruction level in the cost model. It needs to be accounted for elsewhere to accurately cost things like repeated constants and loop invariant instructions. During loop vectorization you would expect them to be loop invariant, so should cost roughly 0. The same can happen for SLP in many cases.

For this case it is probably OK if it fixes the regression, but I'm not sure we would want to push it much further without a higher level solution.

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


More information about the llvm-commits mailing list