[llvm] [AArch64][GlobalISel] Combine G_EXTRACT_VECTOR_ELT and G_BUILD_VECTOR sequences into G_SHUFFLE_VECTOR (PR #110545)

Amara Emerson via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 10:24:47 PDT 2024


aemerson wrote:

So while I see some nice code quality improvements in the tests, I'm not convinced this is a good transformation to make in the general case. The problem is that vector extracts->inserts are simple operations and a shuffle is in general a large and expensive operation, unless it can be pattern matched to a more precise variant like zip. For AArch64, `tbl` is an expensive operation that requires a load from a constant pool to materialize the indices, as well as the actual `tbl` itself.

In your example in this PR description, your input could have been optimized instead into a G_CONCAT_VECTOR right? More specific operations are usually faster and they're also easier for other optimizations to reason about. Shuffles suffer from the problem that they're more opaque unless we do expensive analysis.

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


More information about the llvm-commits mailing list