[llvm] [LoopIdiomVectorize] Recognize and transform minidx pattern (PR #144987)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 10 05:07:05 PDT 2025


david-arm wrote:

> My understanding is that there's two ways to optimise this:
> 
> * GVN, which is the scalar optimisation we are talking about it. GCC is doing this PRE, and that's how this came up, as a case where we are behind.
> * But GVN and NewGVN is a difficult story, and then we found that vectorisation is actually the much better approach. The vectorisation performance gain is much bigger than the gain we get from PRE and GVN.
> 
> Isn't that right, or am I missing something, @madhur13490 ?

And the problem is that as soon as someone validly decides to teach GVN to perform load PRE in this case then this code in LoopIdiomVectorize will become dead and you'll probably see a large performance regression because the scalar code has improved. I do understand that improving GVN could take a long while, so I do see an argument for this PR, but beware of the risk. We can't block good improvements in earlier scalar passes based on the fact we no longer recognise the idiom here.

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


More information about the llvm-commits mailing list