[llvm] [SCEVExpander] Fix addrec cost model (PR #106704)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 13:06:03 PDT 2024


nikic wrote:

@preames In canonical mode, SCEVExpander will expand affine addrecs by basing them on a canonical IV instead. In that case, the expansion is indeed different from the cost calculation implemented here. However, the old cost calculation is also very wrong for the canonical mode expansion.

In fact, when I started working on this issue my first approach was to try to accurately represent the canonical mode cost in the simplest case (draft in https://github.com/nikic/llvm-project/commit/56a707840099e3b948be6eb2d9e3527e22fed8e4), before I realized that the current cost calculation is just completely nonsensical and we should fix that instead. It might make sense to also do the more precise estimate of the canonical expansion, but I'm not sure it's worthwhile, especially as I think it's hard to accurately estimate it in all cases, especially if you take into account that the cost of the canonical IV may be amortized over multiple expansions, and LSR is prone to rewriting these into non-canonical form later. 

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


More information about the llvm-commits mailing list