[llvm] [AArch64][GlobalISel] Combine G_EXTRACT_VECTOR_ELT and G_BUILD_VECTOR sequences into G_SHUFFLE_VECTOR (PR #110545)
Thorsten Schütt via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 11:52:32 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,
----------------
tschuett wrote:
There will be comments about style and algorithms. What I really don't like is the pattern. The pattern matches on build vectors, but the combine is about build vectors of extract vector elts.
```
def extract_vector_element_build_to_shuffle_vector2 : GICombineRule<
(defs root:$root, build_fn_matchinfo:$matchinfo),
(match
(G_EXTRACT_VECTOR_ELT $el2, $vec2, $idx2),
(G_EXTRACT_VECTOR_ELT $el1, $vec1, $idx1),
(G_BUILD_VECTOR $root, $el1, $el2):$build,
[{ return Helper.matchCombineExtractToShuffle(*${build}, ${matchinfo}, ${regpair}); }]),
( apply [{ Helper.applyCombineExtractToShuffle(*${build}, ${matchinfo}, ${regpair}); }] )>;
```
This a matcher, but we would copy and paste for many build vector sizes ...
https://github.com/llvm/llvm-project/pull/110545
More information about the llvm-commits
mailing list