[llvm] [AArch64][GlobalISel] Combine G_EXTRACT_VECTOR_ELT and G_BUILD_VECTOR sequences into G_SHUFFLE_VECTOR (PR #110545)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 1 13:14:36 PDT 2024
================
@@ -905,6 +905,16 @@ def extract_vec_elt_build_vec : GICombineRule<
[{ return Helper.matchExtractVecEltBuildVec(*${root}, ${matchinfo}); }]),
(apply [{ Helper.applyExtractVecEltBuildVec(*${root}, ${matchinfo}); }])>;
+def extract_vector_register_to_id_mapping_matchinfo :
+ GIDefMatchData<"SmallVector<std::pair<Register, int>>">;
+def vector_reg_pair_matchinfo :
+ GIDefMatchData<"std::pair<Register, Register>">;
+def extract_vector_element_build_vector_to_shuffle_vector : GICombineRule<
+ (defs root:$root, extract_vector_register_to_id_mapping_matchinfo:$matchinfo, vector_reg_pair_matchinfo:$regpair),
+ (match (wip_match_opcode G_BUILD_VECTOR):$root,
----------------
ValentijnvdBeek wrote:
Thanks for the review, sorry for committing something that you really don't like. I hope that are things about it you do enjoy. I really appreciate the link. I missed it when I looked for something like it before and I am happy with any information about tablegen that I can find.
In this case, I am not entirely sure if it is exactly the right solution. As you mention, there are a lot of sizes to take into account. For the backend that I am the most for familiar with, AI Engine, the vector size is a maximum of 2048 and a minimum scalar size of 8. So that has 256 patterns to match for both this combiner and the three around it (that use the same pattern). I think we only need to do the powers of 2 and 3 (AMDGPU), so that makes it about ~14 patterns or ~42 in total.
Another reservation that I have is that in this case, complete enumeration is a bit difficult. There is always possible that there is an architecture that has a vector size that just a bit larger or has a different size than the others. By enumerating explicitly, future/alternatives backends need to remember/know to update this combiner specifically.
However, this is my first contribution to LLVM. So these are just, somewhat layman, considerations. If you think that they are not as relevant as I think, than I more willing to change the pattern and also update the combiners around it with the same pattern.
https://github.com/llvm/llvm-project/pull/110545
More information about the llvm-commits
mailing list