xref: /freebsd-src/contrib/llvm-project/llvm/lib/Target/AArch64/AArch64Combine.td (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
15f757f3fSDimitry Andric//=- AArch64Combine.td - Define AArch64 Combine Rules ---------*-tablegen -*-=//
28bcb0991SDimitry Andric//
38bcb0991SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
48bcb0991SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
58bcb0991SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
68bcb0991SDimitry Andric//
78bcb0991SDimitry Andric//===----------------------------------------------------------------------===//
88bcb0991SDimitry Andric//
98bcb0991SDimitry Andric//
108bcb0991SDimitry Andric//===----------------------------------------------------------------------===//
118bcb0991SDimitry Andric
128bcb0991SDimitry Andricinclude "llvm/Target/GlobalISel/Combine.td"
138bcb0991SDimitry Andric
145ffd83dbSDimitry Andricdef fconstant_to_constant : GICombineRule<
155ffd83dbSDimitry Andric  (defs root:$root),
165ffd83dbSDimitry Andric  (match (wip_match_opcode G_FCONSTANT):$root,
175ffd83dbSDimitry Andric         [{ return matchFConstantToConstant(*${root}, MRI); }]),
185ffd83dbSDimitry Andric  (apply [{ applyFConstantToConstant(*${root}); }])>;
195ffd83dbSDimitry Andric
20fe6060f1SDimitry Andricdef icmp_redundant_trunc_matchdata : GIDefMatchData<"Register">;
21fe6060f1SDimitry Andricdef icmp_redundant_trunc : GICombineRule<
22fe6060f1SDimitry Andric  (defs root:$root, icmp_redundant_trunc_matchdata:$matchinfo),
23fe6060f1SDimitry Andric  (match (wip_match_opcode G_ICMP):$root,
24fe6060f1SDimitry Andric         [{ return matchICmpRedundantTrunc(*${root}, MRI, Helper.getKnownBits(), ${matchinfo}); }]),
25fe6060f1SDimitry Andric  (apply [{ applyICmpRedundantTrunc(*${root}, MRI, B, Observer, ${matchinfo}); }])>;
26fe6060f1SDimitry Andric
27fe6060f1SDimitry Andric// AArch64-specific offset folding for G_GLOBAL_VALUE.
28fe6060f1SDimitry Andricdef fold_global_offset_matchdata : GIDefMatchData<"std::pair<uint64_t, uint64_t>">;
29fe6060f1SDimitry Andricdef fold_global_offset : GICombineRule<
30fe6060f1SDimitry Andric  (defs root:$root, fold_global_offset_matchdata:$matchinfo),
31fe6060f1SDimitry Andric  (match (wip_match_opcode G_GLOBAL_VALUE):$root,
32fe6060f1SDimitry Andric          [{ return matchFoldGlobalOffset(*${root}, MRI, ${matchinfo}); }]),
3306c3fb27SDimitry Andric  (apply [{ applyFoldGlobalOffset(*${root}, MRI, B, Observer, ${matchinfo});}])
34fe6060f1SDimitry Andric>;
35fe6060f1SDimitry Andric
365f757f3fSDimitry Andric// Boolean: 0 = G_ZEXT, 1 = G_SEXT
375f757f3fSDimitry Andricdef ext_addv_to_udot_addv_matchinfo : GIDefMatchData<"std::tuple<Register, Register, bool>">;
385f757f3fSDimitry Andriclet Predicates = [HasDotProd] in {
395f757f3fSDimitry Andricdef ext_addv_to_udot_addv : GICombineRule<
405f757f3fSDimitry Andric  (defs root:$root, ext_addv_to_udot_addv_matchinfo:$matchinfo),
415f757f3fSDimitry Andric  (match (wip_match_opcode G_VECREDUCE_ADD):$root,
425f757f3fSDimitry Andric         [{ return matchExtAddvToUdotAddv(*${root}, MRI, STI, ${matchinfo}); }]),
435f757f3fSDimitry Andric  (apply [{ applyExtAddvToUdotAddv(*${root}, MRI, B, Observer, STI, ${matchinfo}); }])
445f757f3fSDimitry Andric>;
455f757f3fSDimitry Andric}
465f757f3fSDimitry Andric
477a6dacacSDimitry Andricdef ext_uaddv_to_uaddlv_matchinfo : GIDefMatchData<"std::pair<Register, bool>">;
487a6dacacSDimitry Andricdef ext_uaddv_to_uaddlv : GICombineRule<
497a6dacacSDimitry Andric  (defs root:$root, ext_uaddv_to_uaddlv_matchinfo:$matchinfo),
507a6dacacSDimitry Andric  (match (wip_match_opcode G_VECREDUCE_ADD):$root,
517a6dacacSDimitry Andric         [{ return matchExtUaddvToUaddlv(*${root}, MRI, ${matchinfo}); }]),
527a6dacacSDimitry Andric  (apply [{ applyExtUaddvToUaddlv(*${root}, MRI, B, Observer, ${matchinfo}); }])
537a6dacacSDimitry Andric>;
547a6dacacSDimitry Andric
55*0fca6ea1SDimitry Andricclass push_opcode_through_ext<Instruction opcode, Instruction extOpcode> : GICombineRule <
56*0fca6ea1SDimitry Andric  (defs root:$root),
57*0fca6ea1SDimitry Andric  (match (extOpcode $ext1, $src1):$ExtMI,
58*0fca6ea1SDimitry Andric         (extOpcode $ext2, $src2),
59*0fca6ea1SDimitry Andric         (opcode $dst, $ext1, $ext2):$root,
60*0fca6ea1SDimitry Andric         [{ return matchPushAddSubExt(*${root}, MRI, ${dst}.getReg(), ${src1}.getReg(), ${src2}.getReg()); }]),
61*0fca6ea1SDimitry Andric  (apply [{ applyPushAddSubExt(*${root}, MRI, B, ${ExtMI}->getOpcode() == TargetOpcode::G_SEXT, ${dst}.getReg(), ${src1}.getReg(), ${src2}.getReg()); }])>;
62*0fca6ea1SDimitry Andric
63*0fca6ea1SDimitry Andricdef push_sub_through_zext : push_opcode_through_ext<G_SUB, G_ZEXT>;
64*0fca6ea1SDimitry Andricdef push_add_through_zext : push_opcode_through_ext<G_ADD, G_ZEXT>;
65*0fca6ea1SDimitry Andricdef push_sub_through_sext : push_opcode_through_ext<G_SUB, G_SEXT>;
66*0fca6ea1SDimitry Andricdef push_add_through_sext : push_opcode_through_ext<G_ADD, G_SEXT>;
67*0fca6ea1SDimitry Andric
685f757f3fSDimitry Andricdef AArch64PreLegalizerCombiner: GICombiner<
6906c3fb27SDimitry Andric  "AArch64PreLegalizerCombinerImpl", [all_combines,
70fe6060f1SDimitry Andric                                      fconstant_to_constant,
71fe6060f1SDimitry Andric                                      icmp_redundant_trunc,
725f757f3fSDimitry Andric                                      fold_global_offset,
735f757f3fSDimitry Andric                                      shuffle_to_extract,
747a6dacacSDimitry Andric                                      ext_addv_to_udot_addv,
75*0fca6ea1SDimitry Andric                                      ext_uaddv_to_uaddlv,
76*0fca6ea1SDimitry Andric                                      push_sub_through_zext,
77*0fca6ea1SDimitry Andric                                      push_add_through_zext,
78*0fca6ea1SDimitry Andric                                      push_sub_through_sext,
79*0fca6ea1SDimitry Andric                                      push_add_through_sext]> {
805f757f3fSDimitry Andric  let CombineAllMethodName = "tryCombineAllImpl";
815ffd83dbSDimitry Andric}
825ffd83dbSDimitry Andric
835f757f3fSDimitry Andricdef AArch64O0PreLegalizerCombiner: GICombiner<
8406c3fb27SDimitry Andric  "AArch64O0PreLegalizerCombinerImpl", [optnone_combines]> {
855f757f3fSDimitry Andric  let CombineAllMethodName = "tryCombineAllImpl";
86fe6060f1SDimitry Andric}
87fe6060f1SDimitry Andric
885ffd83dbSDimitry Andric// Matchdata for combines which replace a G_SHUFFLE_VECTOR with a
895ffd83dbSDimitry Andric// target-specific opcode.
905ffd83dbSDimitry Andricdef shuffle_matchdata : GIDefMatchData<"ShuffleVectorPseudo">;
915ffd83dbSDimitry Andric
925ffd83dbSDimitry Andricdef rev : GICombineRule<
935ffd83dbSDimitry Andric  (defs root:$root, shuffle_matchdata:$matchinfo),
945ffd83dbSDimitry Andric  (match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
955ffd83dbSDimitry Andric         [{ return matchREV(*${root}, MRI, ${matchinfo}); }]),
965ffd83dbSDimitry Andric  (apply [{ applyShuffleVectorPseudo(*${root}, ${matchinfo}); }])
975ffd83dbSDimitry Andric>;
985ffd83dbSDimitry Andric
995ffd83dbSDimitry Andricdef zip : GICombineRule<
1005ffd83dbSDimitry Andric  (defs root:$root, shuffle_matchdata:$matchinfo),
1015ffd83dbSDimitry Andric  (match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
1025ffd83dbSDimitry Andric         [{ return matchZip(*${root}, MRI, ${matchinfo}); }]),
1035ffd83dbSDimitry Andric  (apply [{ applyShuffleVectorPseudo(*${root}, ${matchinfo}); }])
1045ffd83dbSDimitry Andric>;
1055ffd83dbSDimitry Andric
1065ffd83dbSDimitry Andricdef uzp : GICombineRule<
1075ffd83dbSDimitry Andric  (defs root:$root, shuffle_matchdata:$matchinfo),
1085ffd83dbSDimitry Andric  (match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
1095ffd83dbSDimitry Andric         [{ return matchUZP(*${root}, MRI, ${matchinfo}); }]),
1105ffd83dbSDimitry Andric  (apply [{ applyShuffleVectorPseudo(*${root}, ${matchinfo}); }])
1115ffd83dbSDimitry Andric>;
1125ffd83dbSDimitry Andric
1135ffd83dbSDimitry Andricdef dup: GICombineRule <
1145ffd83dbSDimitry Andric  (defs root:$root, shuffle_matchdata:$matchinfo),
1155ffd83dbSDimitry Andric  (match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
1165ffd83dbSDimitry Andric         [{ return matchDup(*${root}, MRI, ${matchinfo}); }]),
1175ffd83dbSDimitry Andric  (apply [{ applyShuffleVectorPseudo(*${root}, ${matchinfo}); }])
1185ffd83dbSDimitry Andric>;
1195ffd83dbSDimitry Andric
1205ffd83dbSDimitry Andricdef trn : GICombineRule<
1215ffd83dbSDimitry Andric  (defs root:$root, shuffle_matchdata:$matchinfo),
1225ffd83dbSDimitry Andric  (match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
1235ffd83dbSDimitry Andric         [{ return matchTRN(*${root}, MRI, ${matchinfo}); }]),
1245ffd83dbSDimitry Andric  (apply [{ applyShuffleVectorPseudo(*${root}, ${matchinfo}); }])
1255ffd83dbSDimitry Andric>;
1265ffd83dbSDimitry Andric
1275ffd83dbSDimitry Andricdef ext: GICombineRule <
1285ffd83dbSDimitry Andric  (defs root:$root, shuffle_matchdata:$matchinfo),
1295ffd83dbSDimitry Andric  (match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
1305ffd83dbSDimitry Andric         [{ return matchEXT(*${root}, MRI, ${matchinfo}); }]),
1315ffd83dbSDimitry Andric  (apply [{ applyEXT(*${root}, ${matchinfo}); }])
1325ffd83dbSDimitry Andric>;
1335ffd83dbSDimitry Andric
134*0fca6ea1SDimitry Andricdef insertelt_nonconst: GICombineRule <
135*0fca6ea1SDimitry Andric  (defs root:$root, shuffle_matchdata:$matchinfo),
136*0fca6ea1SDimitry Andric  (match (wip_match_opcode G_INSERT_VECTOR_ELT):$root,
137*0fca6ea1SDimitry Andric         [{ return matchNonConstInsert(*${root}, MRI); }]),
138*0fca6ea1SDimitry Andric  (apply [{ applyNonConstInsert(*${root}, MRI, B); }])
139*0fca6ea1SDimitry Andric>;
140*0fca6ea1SDimitry Andric
141fe6060f1SDimitry Andricdef shuf_to_ins_matchdata : GIDefMatchData<"std::tuple<Register, int, Register, int>">;
142fe6060f1SDimitry Andricdef shuf_to_ins: GICombineRule <
143fe6060f1SDimitry Andric  (defs root:$root, shuf_to_ins_matchdata:$matchinfo),
144fe6060f1SDimitry Andric  (match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
145fe6060f1SDimitry Andric         [{ return matchINS(*${root}, MRI, ${matchinfo}); }]),
14606c3fb27SDimitry Andric  (apply [{ applyINS(*${root}, MRI, B, ${matchinfo}); }])
147fe6060f1SDimitry Andric>;
1485ffd83dbSDimitry Andric
149e8d8bef9SDimitry Andricdef vashr_vlshr_imm_matchdata : GIDefMatchData<"int64_t">;
150e8d8bef9SDimitry Andricdef vashr_vlshr_imm : GICombineRule<
151e8d8bef9SDimitry Andric  (defs root:$root, vashr_vlshr_imm_matchdata:$matchinfo),
152e8d8bef9SDimitry Andric  (match (wip_match_opcode G_ASHR, G_LSHR):$root,
153e8d8bef9SDimitry Andric          [{ return matchVAshrLshrImm(*${root}, MRI, ${matchinfo}); }]),
154e8d8bef9SDimitry Andric  (apply [{ applyVAshrLshrImm(*${root}, MRI, ${matchinfo}); }])
155e8d8bef9SDimitry Andric>;
156e8d8bef9SDimitry Andric
157e8d8bef9SDimitry Andricdef form_duplane_matchdata :
158e8d8bef9SDimitry Andric  GIDefMatchData<"std::pair<unsigned, int>">;
159e8d8bef9SDimitry Andricdef form_duplane : GICombineRule <
160e8d8bef9SDimitry Andric  (defs root:$root, form_duplane_matchdata:$matchinfo),
161e8d8bef9SDimitry Andric  (match (wip_match_opcode G_SHUFFLE_VECTOR):$root,
162e8d8bef9SDimitry Andric          [{ return matchDupLane(*${root}, MRI, ${matchinfo}); }]),
163e8d8bef9SDimitry Andric  (apply [{ applyDupLane(*${root}, MRI, B, ${matchinfo}); }])
164e8d8bef9SDimitry Andric>;
165e8d8bef9SDimitry Andric
166fe6060f1SDimitry Andricdef shuffle_vector_lowering : GICombineGroup<[dup, rev, ext, zip, uzp, trn,
167*0fca6ea1SDimitry Andric                                              form_duplane, shuf_to_ins]>;
168fe6060f1SDimitry Andric
169cb14a3feSDimitry Andric// Turn G_UNMERGE_VALUES -> G_EXTRACT_VECTOR_ELT's
170cb14a3feSDimitry Andricdef vector_unmerge_lowering : GICombineRule <
171cb14a3feSDimitry Andric  (defs root:$root),
172cb14a3feSDimitry Andric  (match (wip_match_opcode G_UNMERGE_VALUES):$root,
173cb14a3feSDimitry Andric          [{ return matchScalarizeVectorUnmerge(*${root}, MRI); }]),
174cb14a3feSDimitry Andric  (apply [{ applyScalarizeVectorUnmerge(*${root}, MRI, B); }])
175cb14a3feSDimitry Andric>;
176cb14a3feSDimitry Andric
177e8d8bef9SDimitry Andricdef adjust_icmp_imm_matchdata :
178e8d8bef9SDimitry Andric  GIDefMatchData<"std::pair<uint64_t, CmpInst::Predicate>">;
179e8d8bef9SDimitry Andricdef adjust_icmp_imm : GICombineRule <
180e8d8bef9SDimitry Andric  (defs root:$root, adjust_icmp_imm_matchdata:$matchinfo),
181e8d8bef9SDimitry Andric  (match (wip_match_opcode G_ICMP):$root,
182e8d8bef9SDimitry Andric          [{ return matchAdjustICmpImmAndPred(*${root}, MRI, ${matchinfo}); }]),
183e8d8bef9SDimitry Andric  (apply [{ applyAdjustICmpImmAndPred(*${root}, ${matchinfo}, B, Observer); }])
184e8d8bef9SDimitry Andric>;
185e8d8bef9SDimitry Andric
186fe6060f1SDimitry Andricdef swap_icmp_operands : GICombineRule <
187fe6060f1SDimitry Andric  (defs root:$root),
188fe6060f1SDimitry Andric  (match (wip_match_opcode G_ICMP):$root,
189fe6060f1SDimitry Andric          [{ return trySwapICmpOperands(*${root}, MRI); }]),
190fe6060f1SDimitry Andric  (apply [{ applySwapICmpOperands(*${root}, Observer); }])
191fe6060f1SDimitry Andric>;
192fe6060f1SDimitry Andric
193fe6060f1SDimitry Andricdef icmp_lowering : GICombineGroup<[adjust_icmp_imm, swap_icmp_operands]>;
194e8d8bef9SDimitry Andric
195e8d8bef9SDimitry Andricdef extractvecelt_pairwise_add_matchdata : GIDefMatchData<"std::tuple<unsigned, LLT, Register>">;
196e8d8bef9SDimitry Andricdef extractvecelt_pairwise_add : GICombineRule<
197e8d8bef9SDimitry Andric  (defs root:$root, extractvecelt_pairwise_add_matchdata:$matchinfo),
198e8d8bef9SDimitry Andric  (match (wip_match_opcode G_EXTRACT_VECTOR_ELT):$root,
199e8d8bef9SDimitry Andric          [{ return matchExtractVecEltPairwiseAdd(*${root}, MRI, ${matchinfo}); }]),
200e8d8bef9SDimitry Andric  (apply [{ applyExtractVecEltPairwiseAdd(*${root}, MRI, B, ${matchinfo}); }])
201e8d8bef9SDimitry Andric>;
202e8d8bef9SDimitry Andric
203e8d8bef9SDimitry Andricdef mul_const_matchdata : GIDefMatchData<"std::function<void(MachineIRBuilder&, Register)>">;
204e8d8bef9SDimitry Andricdef mul_const : GICombineRule<
205e8d8bef9SDimitry Andric  (defs root:$root, mul_const_matchdata:$matchinfo),
206e8d8bef9SDimitry Andric  (match (wip_match_opcode G_MUL):$root,
207e8d8bef9SDimitry Andric          [{ return matchAArch64MulConstCombine(*${root}, MRI, ${matchinfo}); }]),
208e8d8bef9SDimitry Andric  (apply [{ applyAArch64MulConstCombine(*${root}, MRI, B, ${matchinfo}); }])
209e8d8bef9SDimitry Andric>;
210e8d8bef9SDimitry Andric
2115f757f3fSDimitry Andricdef lower_mull : GICombineRule<
2125f757f3fSDimitry Andric  (defs root:$root),
2135f757f3fSDimitry Andric  (match (wip_match_opcode G_MUL):$root,
2145f757f3fSDimitry Andric          [{ return matchExtMulToMULL(*${root}, MRI); }]),
2155f757f3fSDimitry Andric  (apply [{ applyExtMulToMULL(*${root}, MRI, B, Observer); }])
2165f757f3fSDimitry Andric>;
2175f757f3fSDimitry Andric
218fe6060f1SDimitry Andricdef build_vector_to_dup : GICombineRule<
219fe6060f1SDimitry Andric  (defs root:$root),
220fe6060f1SDimitry Andric  (match (wip_match_opcode G_BUILD_VECTOR):$root,
221fe6060f1SDimitry Andric          [{ return matchBuildVectorToDup(*${root}, MRI); }]),
22206c3fb27SDimitry Andric  (apply [{ applyBuildVectorToDup(*${root}, MRI, B); }])
223fe6060f1SDimitry Andric>;
224fe6060f1SDimitry Andric
225fe6060f1SDimitry Andricdef build_vector_lowering : GICombineGroup<[build_vector_to_dup]>;
226fe6060f1SDimitry Andric
227fe6060f1SDimitry Andricdef lower_vector_fcmp : GICombineRule<
228fe6060f1SDimitry Andric  (defs root:$root),
229fe6060f1SDimitry Andric  (match (wip_match_opcode G_FCMP):$root,
23006c3fb27SDimitry Andric    [{ return matchLowerVectorFCMP(*${root}, MRI, B); }]),
23106c3fb27SDimitry Andric  (apply [{ applyLowerVectorFCMP(*${root}, MRI, B); }])>;
232fe6060f1SDimitry Andric
233fe6060f1SDimitry Andricdef form_truncstore_matchdata : GIDefMatchData<"Register">;
234fe6060f1SDimitry Andricdef form_truncstore : GICombineRule<
235fe6060f1SDimitry Andric  (defs root:$root, form_truncstore_matchdata:$matchinfo),
236fe6060f1SDimitry Andric  (match (wip_match_opcode G_STORE):$root,
237fe6060f1SDimitry Andric          [{ return matchFormTruncstore(*${root}, MRI, ${matchinfo}); }]),
238fe6060f1SDimitry Andric  (apply [{ applyFormTruncstore(*${root}, MRI, B, Observer, ${matchinfo}); }])
239fe6060f1SDimitry Andric>;
240fe6060f1SDimitry Andric
241fe6060f1SDimitry Andricdef fold_merge_to_zext : GICombineRule<
242fe6060f1SDimitry Andric  (defs root:$d),
243fe6060f1SDimitry Andric  (match (wip_match_opcode G_MERGE_VALUES):$d,
244fe6060f1SDimitry Andric          [{ return matchFoldMergeToZext(*${d}, MRI); }]),
245fe6060f1SDimitry Andric  (apply [{ applyFoldMergeToZext(*${d}, MRI, B, Observer); }])
246fe6060f1SDimitry Andric>;
247fe6060f1SDimitry Andric
248349cc55cSDimitry Andricdef mutate_anyext_to_zext : GICombineRule<
249349cc55cSDimitry Andric  (defs root:$d),
250349cc55cSDimitry Andric  (match (wip_match_opcode G_ANYEXT):$d,
251349cc55cSDimitry Andric          [{ return matchMutateAnyExtToZExt(*${d}, MRI); }]),
252349cc55cSDimitry Andric  (apply [{ applyMutateAnyExtToZExt(*${d}, MRI, B, Observer); }])
253349cc55cSDimitry Andric>;
254349cc55cSDimitry Andric
2550eae32dcSDimitry Andricdef split_store_zero_128 : GICombineRule<
2560eae32dcSDimitry Andric  (defs root:$d),
2570eae32dcSDimitry Andric  (match (wip_match_opcode G_STORE):$d,
2580eae32dcSDimitry Andric          [{ return matchSplitStoreZero128(*${d}, MRI); }]),
2590eae32dcSDimitry Andric  (apply [{ applySplitStoreZero128(*${d}, MRI, B, Observer); }])
2600eae32dcSDimitry Andric>;
2610eae32dcSDimitry Andric
262bdd1243dSDimitry Andricdef vector_sext_inreg_to_shift : GICombineRule<
263bdd1243dSDimitry Andric  (defs root:$d),
264bdd1243dSDimitry Andric  (match (wip_match_opcode G_SEXT_INREG):$d,
265bdd1243dSDimitry Andric          [{ return matchVectorSextInReg(*${d}, MRI); }]),
266bdd1243dSDimitry Andric  (apply [{ applyVectorSextInReg(*${d}, MRI, B, Observer); }])
267bdd1243dSDimitry Andric>;
268bdd1243dSDimitry Andric
2695f757f3fSDimitry Andricdef unmerge_ext_to_unmerge_matchdata : GIDefMatchData<"Register">;
2705f757f3fSDimitry Andricdef unmerge_ext_to_unmerge : GICombineRule<
2715f757f3fSDimitry Andric  (defs root:$d, unmerge_ext_to_unmerge_matchdata:$matchinfo),
2725f757f3fSDimitry Andric  (match (wip_match_opcode G_UNMERGE_VALUES):$d,
2735f757f3fSDimitry Andric          [{ return matchUnmergeExtToUnmerge(*${d}, MRI, ${matchinfo}); }]),
2745f757f3fSDimitry Andric  (apply [{ applyUnmergeExtToUnmerge(*${d}, MRI, B, Observer, ${matchinfo}); }])
2755f757f3fSDimitry Andric>;
2765f757f3fSDimitry Andric
2775f757f3fSDimitry Andricdef regtriple_matchdata : GIDefMatchData<"std::tuple<Register, Register, Register>">;
2785f757f3fSDimitry Andricdef or_to_bsp: GICombineRule <
2795f757f3fSDimitry Andric  (defs root:$root, regtriple_matchdata:$matchinfo),
2805f757f3fSDimitry Andric  (match (wip_match_opcode G_OR):$root,
2815f757f3fSDimitry Andric         [{ return matchOrToBSP(*${root}, MRI, ${matchinfo}); }]),
2825f757f3fSDimitry Andric  (apply [{ applyOrToBSP(*${root}, MRI, B, ${matchinfo}); }])
2835f757f3fSDimitry Andric>;
2845f757f3fSDimitry Andric
285*0fca6ea1SDimitry Andric// Combines Mul(And(Srl(X, 15), 0x10001), 0xffff) into CMLTz
286*0fca6ea1SDimitry Andricdef combine_mul_cmlt : GICombineRule<
287*0fca6ea1SDimitry Andric  (defs root:$root, register_matchinfo:$matchinfo),
288*0fca6ea1SDimitry Andric  (match (wip_match_opcode G_MUL):$root,
289*0fca6ea1SDimitry Andric        [{ return matchCombineMulCMLT(*${root}, MRI, ${matchinfo}); }]),
290*0fca6ea1SDimitry Andric  (apply [{ applyCombineMulCMLT(*${root}, MRI, B, ${matchinfo}); }])
291*0fca6ea1SDimitry Andric>;
292*0fca6ea1SDimitry Andric
293e8d8bef9SDimitry Andric// Post-legalization combines which should happen at all optimization levels.
294e8d8bef9SDimitry Andric// (E.g. ones that facilitate matching for the selector) For example, matching
295e8d8bef9SDimitry Andric// pseudos.
29606c3fb27SDimitry Andricdef AArch64PostLegalizerLowering
2975f757f3fSDimitry Andric    : GICombiner<"AArch64PostLegalizerLoweringImpl",
298fe6060f1SDimitry Andric                       [shuffle_vector_lowering, vashr_vlshr_imm,
299fe6060f1SDimitry Andric                        icmp_lowering, build_vector_lowering,
300bdd1243dSDimitry Andric                        lower_vector_fcmp, form_truncstore,
3015f757f3fSDimitry Andric                        vector_sext_inreg_to_shift,
302cb14a3feSDimitry Andric                        unmerge_ext_to_unmerge, lower_mull,
303*0fca6ea1SDimitry Andric                        vector_unmerge_lowering, insertelt_nonconst]> {
304e8d8bef9SDimitry Andric}
305e8d8bef9SDimitry Andric
306e8d8bef9SDimitry Andric// Post-legalization combines which are primarily optimizations.
30706c3fb27SDimitry Andricdef AArch64PostLegalizerCombiner
3085f757f3fSDimitry Andric    : GICombiner<"AArch64PostLegalizerCombinerImpl",
30981ad6265SDimitry Andric                       [copy_prop, combines_for_extload,
3105f757f3fSDimitry Andric                        combine_indexed_load_store,
311349cc55cSDimitry Andric                        sext_trunc_sextload, mutate_anyext_to_zext,
312e8d8bef9SDimitry Andric                        hoist_logic_op_with_same_opcode_hands,
313e8d8bef9SDimitry Andric                        redundant_and, xor_of_and_with_same_reg,
314e8d8bef9SDimitry Andric                        extractvecelt_pairwise_add, redundant_or,
315fe6060f1SDimitry Andric                        mul_const, redundant_sext_inreg,
316fe6060f1SDimitry Andric                        form_bitfield_extract, rotate_out_of_range,
317fe6060f1SDimitry Andric                        icmp_to_true_false_known_bits, merge_unmerge,
318fe6060f1SDimitry Andric                        select_combines, fold_merge_to_zext,
3195f757f3fSDimitry Andric                        constant_fold_binops, identity_combines,
3200eae32dcSDimitry Andric                        ptr_add_immed_chain, overlapping_and,
321bdd1243dSDimitry Andric                        split_store_zero_128, undef_combines,
322*0fca6ea1SDimitry Andric                        select_to_minmax, or_to_bsp, combine_concat_vector,
323*0fca6ea1SDimitry Andric                        commute_constant_to_rhs,
324*0fca6ea1SDimitry Andric                        push_freeze_to_prevent_poison_from_propagating,
325*0fca6ea1SDimitry Andric                        combine_mul_cmlt]> {
3268bcb0991SDimitry Andric}
327