File: | build/llvm-toolchain-snapshot-16~++20220929111209+ac2e2d659819/build-llvm/tools/clang/stage2-bins/lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc |
Warning: | line 2561, column 7 Value stored to 'Partition' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
2 | |* *| |
3 | |* Global Combiner *| |
4 | |* *| |
5 | |* Automatically generated file, do not edit! *| |
6 | |* *| |
7 | \*===----------------------------------------------------------------------===*/ |
8 | |
9 | #ifdef AARCH64PRELEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_DEPS |
10 | #include "llvm/ADT/SparseBitVector.h" |
11 | namespace llvm { |
12 | extern cl::OptionCategory GICombinerOptionCategory; |
13 | } // end namespace llvm |
14 | #endif // ifdef AARCH64PRELEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_DEPS |
15 | |
16 | #ifdef AARCH64PRELEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_H |
17 | class AArch64GenPreLegalizerCombinerHelperRuleConfig { |
18 | SparseBitVector<> DisabledRules; |
19 | |
20 | public: |
21 | bool parseCommandLineOption(); |
22 | bool isRuleDisabled(unsigned ID) const; |
23 | bool setRuleEnabled(StringRef RuleIdentifier); |
24 | bool setRuleDisabled(StringRef RuleIdentifier); |
25 | }; |
26 | |
27 | class AArch64GenPreLegalizerCombinerHelper : public AArch64PreLegalizerCombinerHelperState { |
28 | const AArch64GenPreLegalizerCombinerHelperRuleConfig *RuleConfig; |
29 | |
30 | public: |
31 | template <typename... Args>AArch64GenPreLegalizerCombinerHelper(const AArch64GenPreLegalizerCombinerHelperRuleConfig &RuleConfig, Args &&... args) : AArch64PreLegalizerCombinerHelperState(std::forward<Args>(args)...), RuleConfig(&RuleConfig) {} |
32 | |
33 | bool tryCombineAll( |
34 | GISelChangeObserver &Observer, |
35 | MachineInstr &MI, |
36 | MachineIRBuilder &B) const; |
37 | }; |
38 | |
39 | static Optional<uint64_t> getRuleIdxForIdentifier(StringRef RuleIdentifier) { |
40 | uint64_t I; |
41 | // getAtInteger(...) returns false on success |
42 | bool Parsed = !RuleIdentifier.getAsInteger(0, I); |
43 | if (Parsed) |
44 | return I; |
45 | |
46 | #ifndef NDEBUG |
47 | switch (RuleIdentifier.size()) { |
48 | default: break; |
49 | case 9: // 5 strings to match. |
50 | switch (RuleIdentifier[0]) { |
51 | default: break; |
52 | case 'a': // 1 string to match. |
53 | if (memcmp(RuleIdentifier.data()+1, "ddo_by_0", 8) != 0) |
54 | break; |
55 | return 67; // "addo_by_0" |
56 | case 'c': // 1 string to match. |
57 | if (memcmp(RuleIdentifier.data()+1, "opy_prop", 8) != 0) |
58 | break; |
59 | return 0; // "copy_prop" |
60 | case 'm': // 2 strings to match. |
61 | if (memcmp(RuleIdentifier.data()+1, "ulo_by_", 7) != 0) |
62 | break; |
63 | switch (RuleIdentifier[8]) { |
64 | default: break; |
65 | case '0': // 1 string to match. |
66 | return 66; // "mulo_by_0" |
67 | case '2': // 1 string to match. |
68 | return 65; // "mulo_by_2" |
69 | } |
70 | break; |
71 | case 't': // 1 string to match. |
72 | if (memcmp(RuleIdentifier.data()+1, "runc_shl", 8) != 0) |
73 | break; |
74 | return 61; // "trunc_shl" |
75 | } |
76 | break; |
77 | case 10: // 3 strings to match. |
78 | switch (RuleIdentifier[0]) { |
79 | default: break; |
80 | case 'i': // 1 string to match. |
81 | if (memcmp(RuleIdentifier.data()+1, "2p_to_p2i", 9) != 0) |
82 | break; |
83 | return 27; // "i2p_to_p2i" |
84 | case 'm': // 1 string to match. |
85 | if (memcmp(RuleIdentifier.data()+1, "ul_to_shl", 9) != 0) |
86 | break; |
87 | return 1; // "mul_to_shl" |
88 | case 'p': // 1 string to match. |
89 | if (memcmp(RuleIdentifier.data()+1, "2i_to_i2p", 9) != 0) |
90 | break; |
91 | return 26; // "p2i_to_i2p" |
92 | } |
93 | break; |
94 | case 11: // 2 strings to match. |
95 | switch (RuleIdentifier[0]) { |
96 | default: break; |
97 | case 'a': // 1 string to match. |
98 | if (memcmp(RuleIdentifier.data()+1, "dd_sub_reg", 10) != 0) |
99 | break; |
100 | return 31; // "add_sub_reg" |
101 | case 'u': // 1 string to match. |
102 | if (memcmp(RuleIdentifier.data()+1, "nmerge_cst", 10) != 0) |
103 | break; |
104 | return 56; // "unmerge_cst" |
105 | } |
106 | break; |
107 | case 12: // 5 strings to match. |
108 | switch (RuleIdentifier[0]) { |
109 | default: break; |
110 | case 'a': // 1 string to match. |
111 | if (memcmp(RuleIdentifier.data()+1, "dde_to_addo", 11) != 0) |
112 | break; |
113 | return 68; // "adde_to_addo" |
114 | case 'e': // 1 string to match. |
115 | if (memcmp(RuleIdentifier.data()+1, "xt_ext_fold", 11) != 0) |
116 | break; |
117 | return 51; // "ext_ext_fold" |
118 | case 'm': // 1 string to match. |
119 | if (memcmp(RuleIdentifier.data()+1, "ulh_to_lshr", 11) != 0) |
120 | break; |
121 | return 87; // "mulh_to_lshr" |
122 | case 'n': // 1 string to match. |
123 | if (memcmp(RuleIdentifier.data()+1, "ot_cmp_fold", 11) != 0) |
124 | break; |
125 | return 52; // "not_cmp_fold" |
126 | case 'r': // 1 string to match. |
127 | if (memcmp(RuleIdentifier.data()+1, "edundant_or", 11) != 0) |
128 | break; |
129 | return 46; // "redundant_or" |
130 | } |
131 | break; |
132 | case 13: // 8 strings to match. |
133 | switch (RuleIdentifier[0]) { |
134 | default: break; |
135 | case 'c': // 1 string to match. |
136 | if (memcmp(RuleIdentifier.data()+1, "onstant_fold", 12) != 0) |
137 | break; |
138 | return 83; // "constant_fold" |
139 | case 'l': // 1 string to match. |
140 | if (memcmp(RuleIdentifier.data()+1, "oad_and_mask", 12) != 0) |
141 | break; |
142 | return 8; // "load_and_mask" |
143 | case 'm': // 1 string to match. |
144 | if (memcmp(RuleIdentifier.data()+1, "erge_unmerge", 12) != 0) |
145 | break; |
146 | return 59; // "merge_unmerge" |
147 | case 'r': // 1 string to match. |
148 | if (memcmp(RuleIdentifier.data()+1, "edundant_and", 12) != 0) |
149 | break; |
150 | return 44; // "redundant_and" |
151 | case 's': // 1 string to match. |
152 | if (memcmp(RuleIdentifier.data()+1, "div_by_const", 12) != 0) |
153 | break; |
154 | return 86; // "sdiv_by_const" |
155 | case 'u': // 3 strings to match. |
156 | switch (RuleIdentifier[1]) { |
157 | default: break; |
158 | case 'd': // 1 string to match. |
159 | if (memcmp(RuleIdentifier.data()+2, "iv_by_const", 11) != 0) |
160 | break; |
161 | return 85; // "udiv_by_const" |
162 | case 'n': // 2 strings to match. |
163 | if (memcmp(RuleIdentifier.data()+2, "merge_", 6) != 0) |
164 | break; |
165 | switch (RuleIdentifier[8]) { |
166 | default: break; |
167 | case 'm': // 1 string to match. |
168 | if (memcmp(RuleIdentifier.data()+9, "erge", 4) != 0) |
169 | break; |
170 | return 54; // "unmerge_merge" |
171 | case 'u': // 1 string to match. |
172 | if (memcmp(RuleIdentifier.data()+9, "ndef", 4) != 0) |
173 | break; |
174 | return 19; // "unmerge_undef" |
175 | } |
176 | break; |
177 | } |
178 | break; |
179 | } |
180 | break; |
181 | case 14: // 8 strings to match. |
182 | switch (RuleIdentifier[0]) { |
183 | default: break; |
184 | case 'b': // 1 string to match. |
185 | if (memcmp(RuleIdentifier.data()+1, "inop_same_val", 13) != 0) |
186 | break; |
187 | return 23; // "binop_same_val" |
188 | case 'c': // 1 string to match. |
189 | if (memcmp(RuleIdentifier.data()+1, "onstant_fp_op", 13) != 0) |
190 | break; |
191 | return 62; // "constant_fp_op" |
192 | case 'f': // 3 strings to match. |
193 | switch (RuleIdentifier[1]) { |
194 | default: break; |
195 | case 'a': // 2 strings to match. |
196 | if (memcmp(RuleIdentifier.data()+2, "bs_f", 4) != 0) |
197 | break; |
198 | switch (RuleIdentifier[6]) { |
199 | default: break; |
200 | case 'a': // 1 string to match. |
201 | if (memcmp(RuleIdentifier.data()+7, "bs_fold", 7) != 0) |
202 | break; |
203 | return 55; // "fabs_fabs_fold" |
204 | case 'n': // 1 string to match. |
205 | if (memcmp(RuleIdentifier.data()+7, "eg_fold", 7) != 0) |
206 | break; |
207 | return 84; // "fabs_fneg_fold" |
208 | } |
209 | break; |
210 | case 'n': // 1 string to match. |
211 | if (memcmp(RuleIdentifier.data()+2, "eg_fneg_fold", 12) != 0) |
212 | break; |
213 | return 29; // "fneg_fneg_fold" |
214 | } |
215 | break; |
216 | case 'm': // 1 string to match. |
217 | if (memcmp(RuleIdentifier.data()+1, "ul_by_neg_one", 13) != 0) |
218 | break; |
219 | return 3; // "mul_by_neg_one" |
220 | case 'r': // 1 string to match. |
221 | if (memcmp(RuleIdentifier.data()+1, "eassoc_ptradd", 13) != 0) |
222 | break; |
223 | return 35; // "reassoc_ptradd" |
224 | case 't': // 1 string to match. |
225 | if (memcmp(RuleIdentifier.data()+1, "runc_ext_fold", 13) != 0) |
226 | break; |
227 | return 60; // "trunc_ext_fold" |
228 | } |
229 | break; |
230 | case 15: // 5 strings to match. |
231 | switch (RuleIdentifier[0]) { |
232 | default: break; |
233 | case 'e': // 1 string to match. |
234 | if (memcmp(RuleIdentifier.data()+1, "xtending_loads", 14) != 0) |
235 | break; |
236 | return 7; // "extending_loads" |
237 | case 'l': // 1 string to match. |
238 | if (memcmp(RuleIdentifier.data()+1, "oad_or_combine", 14) != 0) |
239 | break; |
240 | return 74; // "load_or_combine" |
241 | case 'o': // 1 string to match. |
242 | if (memcmp(RuleIdentifier.data()+1, "verlapping_and", 14) != 0) |
243 | break; |
244 | return 64; // "overlapping_and" |
245 | case 's': // 1 string to match. |
246 | if (memcmp(RuleIdentifier.data()+1, "elect_same_val", 14) != 0) |
247 | break; |
248 | return 21; // "select_same_val" |
249 | case 'z': // 1 string to match. |
250 | if (memcmp(RuleIdentifier.data()+1, "ext_trunc_fold", 14) != 0) |
251 | break; |
252 | return 48; // "zext_trunc_fold" |
253 | } |
254 | break; |
255 | case 16: // 3 strings to match. |
256 | switch (RuleIdentifier[0]) { |
257 | default: break; |
258 | case 's': // 1 string to match. |
259 | if (memcmp(RuleIdentifier.data()+1, "elect_undef_cmp", 15) != 0) |
260 | break; |
261 | return 41; // "select_undef_cmp" |
262 | case 't': // 1 string to match. |
263 | if (memcmp(RuleIdentifier.data()+1, "runcstore_merge", 15) != 0) |
264 | break; |
265 | return 75; // "truncstore_merge" |
266 | case 'u': // 1 string to match. |
267 | if (memcmp(RuleIdentifier.data()+1, "ndef_to_fp_zero", 15) != 0) |
268 | break; |
269 | return 10; // "undef_to_fp_zero" |
270 | } |
271 | break; |
272 | case 17: // 9 strings to match. |
273 | switch (RuleIdentifier[0]) { |
274 | default: break; |
275 | case 'a': // 2 strings to match. |
276 | switch (RuleIdentifier[1]) { |
277 | default: break; |
278 | case 'd': // 1 string to match. |
279 | if (memcmp(RuleIdentifier.data()+2, "d_p2i_to_ptradd", 15) != 0) |
280 | break; |
281 | return 2; // "add_p2i_to_ptradd" |
282 | case 'n': // 1 string to match. |
283 | if (memcmp(RuleIdentifier.data()+2, "yext_trunc_fold", 15) != 0) |
284 | break; |
285 | return 28; // "anyext_trunc_fold" |
286 | } |
287 | break; |
288 | case 'd': // 1 string to match. |
289 | if (memcmp(RuleIdentifier.data()+1, "iv_rem_to_divrem", 16) != 0) |
290 | break; |
291 | return 76; // "div_rem_to_divrem" |
292 | case 'e': // 1 string to match. |
293 | if (memcmp(RuleIdentifier.data()+1, "rase_undef_store", 16) != 0) |
294 | break; |
295 | return 18; // "erase_undef_store" |
296 | case 'p': // 1 string to match. |
297 | if (memcmp(RuleIdentifier.data()+1, "tr_add_with_zero", 16) != 0) |
298 | break; |
299 | return 71; // "ptr_add_with_zero" |
300 | case 's': // 2 strings to match. |
301 | switch (RuleIdentifier[1]) { |
302 | default: break; |
303 | case 'e': // 1 string to match. |
304 | if (memcmp(RuleIdentifier.data()+2, "lect_to_logical", 15) != 0) |
305 | break; |
306 | return 43; // "select_to_logical" |
307 | case 'h': // 1 string to match. |
308 | if (memcmp(RuleIdentifier.data()+2, "ift_immed_chain", 15) != 0) |
309 | break; |
310 | return 72; // "shift_immed_chain" |
311 | } |
312 | break; |
313 | case 'u': // 2 strings to match. |
314 | switch (RuleIdentifier[1]) { |
315 | default: break; |
316 | case 'n': // 1 string to match. |
317 | if (memcmp(RuleIdentifier.data()+2, "def_to_int_zero", 15) != 0) |
318 | break; |
319 | return 11; // "undef_to_int_zero" |
320 | case 'r': // 1 string to match. |
321 | if (memcmp(RuleIdentifier.data()+2, "em_pow2_to_mask", 15) != 0) |
322 | break; |
323 | return 47; // "urem_pow2_to_mask" |
324 | } |
325 | break; |
326 | } |
327 | break; |
328 | case 18: // 5 strings to match. |
329 | switch (RuleIdentifier[0]) { |
330 | default: break; |
331 | case 'b': // 1 string to match. |
332 | if (memcmp(RuleIdentifier.data()+1, "inop_left_to_zero", 17) != 0) |
333 | break; |
334 | return 24; // "binop_left_to_zero" |
335 | case 'c': // 1 string to match. |
336 | if (memcmp(RuleIdentifier.data()+1, "ombine_minmax_nan", 17) != 0) |
337 | break; |
338 | return 69; // "combine_minmax_nan" |
339 | case 'f': // 1 string to match. |
340 | if (memcmp(RuleIdentifier.data()+1, "old_global_offset", 17) != 0) |
341 | break; |
342 | return 101; // "fold_global_offset" |
343 | case 'r': // 1 string to match. |
344 | if (memcmp(RuleIdentifier.data()+1, "ight_identity_one", 17) != 0) |
345 | break; |
346 | return 30; // "right_identity_one" |
347 | case 's': // 1 string to match. |
348 | if (memcmp(RuleIdentifier.data()+1, "ext_inreg_of_load", 17) != 0) |
349 | break; |
350 | return 38; // "sext_inreg_of_load" |
351 | } |
352 | break; |
353 | case 19: // 7 strings to match. |
354 | switch (RuleIdentifier[0]) { |
355 | default: break; |
356 | case 'b': // 1 string to match. |
357 | if (memcmp(RuleIdentifier.data()+1, "inop_right_to_zero", 18) != 0) |
358 | break; |
359 | return 25; // "binop_right_to_zero" |
360 | case 'c': // 1 string to match. |
361 | if (memcmp(RuleIdentifier.data()+1, "onst_ptradd_to_i2p", 18) != 0) |
362 | break; |
363 | return 63; // "const_ptradd_to_i2p" |
364 | case 'e': // 1 string to match. |
365 | if (memcmp(RuleIdentifier.data()+1, "xtend_through_phis", 18) != 0) |
366 | break; |
367 | return 32; // "extend_through_phis" |
368 | case 'p': // 1 string to match. |
369 | if (memcmp(RuleIdentifier.data()+1, "tr_add_immed_chain", 18) != 0) |
370 | break; |
371 | return 36; // "ptr_add_immed_chain" |
372 | case 'r': // 1 string to match. |
373 | if (memcmp(RuleIdentifier.data()+1, "ight_identity_zero", 18) != 0) |
374 | break; |
375 | return 22; // "right_identity_zero" |
376 | case 's': // 2 strings to match. |
377 | switch (RuleIdentifier[1]) { |
378 | default: break; |
379 | case 'e': // 1 string to match. |
380 | if (memcmp(RuleIdentifier.data()+2, "lect_constant_cmp", 17) != 0) |
381 | break; |
382 | return 42; // "select_constant_cmp" |
383 | case 'i': // 1 string to match. |
384 | if (memcmp(RuleIdentifier.data()+2, "mplify_add_to_sub", 17) != 0) |
385 | break; |
386 | return 33; // "simplify_add_to_sub" |
387 | } |
388 | break; |
389 | } |
390 | break; |
391 | case 20: // 5 strings to match. |
392 | switch (RuleIdentifier[0]) { |
393 | default: break; |
394 | case 'a': // 1 string to match. |
395 | if (memcmp(RuleIdentifier.data()+1, "nd_or_disjoint_mask", 19) != 0) |
396 | break; |
397 | return 89; // "and_or_disjoint_mask" |
398 | case 'i': // 1 string to match. |
399 | if (memcmp(RuleIdentifier.data()+1, "cmp_redundant_trunc", 19) != 0) |
400 | break; |
401 | return 100; // "icmp_redundant_trunc" |
402 | case 'r': // 2 strings to match. |
403 | if (memcmp(RuleIdentifier.data()+1, "edu", 3) != 0) |
404 | break; |
405 | switch (RuleIdentifier[4]) { |
406 | default: break; |
407 | case 'c': // 1 string to match. |
408 | if (memcmp(RuleIdentifier.data()+5, "e_shl_of_extend", 15) != 0) |
409 | break; |
410 | return 39; // "reduce_shl_of_extend" |
411 | case 'n': // 1 string to match. |
412 | if (memcmp(RuleIdentifier.data()+5, "dant_sext_inreg", 15) != 0) |
413 | break; |
414 | return 45; // "redundant_sext_inreg" |
415 | } |
416 | break; |
417 | case 'u': // 1 string to match. |
418 | if (memcmp(RuleIdentifier.data()+1, "nmerge_zext_to_zext", 19) != 0) |
419 | break; |
420 | return 58; // "unmerge_zext_to_zext" |
421 | } |
422 | break; |
423 | case 21: // 3 strings to match. |
424 | switch (RuleIdentifier[0]) { |
425 | default: break; |
426 | case 'f': // 1 string to match. |
427 | if (memcmp(RuleIdentifier.data()+1, "constant_to_constant", 20) != 0) |
428 | break; |
429 | return 99; // "fconstant_to_constant" |
430 | case 'u': // 2 strings to match. |
431 | if (RuleIdentifier[1] != 'n') |
432 | break; |
433 | switch (RuleIdentifier[2]) { |
434 | default: break; |
435 | case 'd': // 1 string to match. |
436 | if (memcmp(RuleIdentifier.data()+3, "ef_to_negative_one", 18) != 0) |
437 | break; |
438 | return 12; // "undef_to_negative_one" |
439 | case 'm': // 1 string to match. |
440 | if (memcmp(RuleIdentifier.data()+3, "erge_dead_to_trunc", 18) != 0) |
441 | break; |
442 | return 57; // "unmerge_dead_to_trunc" |
443 | } |
444 | break; |
445 | } |
446 | break; |
447 | case 22: // 6 strings to match. |
448 | switch (RuleIdentifier[0]) { |
449 | default: break; |
450 | case 'f': // 2 strings to match. |
451 | switch (RuleIdentifier[1]) { |
452 | default: break; |
453 | case 'o': // 1 string to match. |
454 | if (memcmp(RuleIdentifier.data()+2, "ld_binop_into_select", 20) != 0) |
455 | break; |
456 | return 98; // "fold_binop_into_select" |
457 | case 'u': // 1 string to match. |
458 | if (memcmp(RuleIdentifier.data()+2, "nnel_shift_to_rotate", 20) != 0) |
459 | break; |
460 | return 78; // "funnel_shift_to_rotate" |
461 | } |
462 | break; |
463 | case 'i': // 1 string to match. |
464 | if (memcmp(RuleIdentifier.data()+1, "cmp_to_lhs_known_bits", 21) != 0) |
465 | break; |
466 | return 50; // "icmp_to_lhs_known_bits" |
467 | case 'p': // 1 string to match. |
468 | if (memcmp(RuleIdentifier.data()+1, "ropagate_undef_any_op", 21) != 0) |
469 | break; |
470 | return 15; // "propagate_undef_any_op" |
471 | case 'r': // 1 string to match. |
472 | if (memcmp(RuleIdentifier.data()+1, "edundant_neg_operands", 21) != 0) |
473 | break; |
474 | return 88; // "redundant_neg_operands" |
475 | case 's': // 1 string to match. |
476 | if (memcmp(RuleIdentifier.data()+1, "hl_ashr_to_sext_inreg", 21) != 0) |
477 | break; |
478 | return 37; // "shl_ashr_to_sext_inreg" |
479 | } |
480 | break; |
481 | case 23: // 1 string to match. |
482 | if (memcmp(RuleIdentifier.data()+0, "propagate_undef_all_ops", 23) != 0) |
483 | break; |
484 | return 16; // "propagate_undef_all_ops" |
485 | case 24: // 3 strings to match. |
486 | switch (RuleIdentifier[0]) { |
487 | default: break; |
488 | case 'b': // 1 string to match. |
489 | if (memcmp(RuleIdentifier.data()+1, "inop_left_undef_to_zero", 23) != 0) |
490 | break; |
491 | return 13; // "binop_left_undef_to_zero" |
492 | case 'n': // 1 string to match. |
493 | if (memcmp(RuleIdentifier.data()+1, "arrow_binop_feeding_and", 23) != 0) |
494 | break; |
495 | return 40; // "narrow_binop_feeding_and" |
496 | case 'x': // 1 string to match. |
497 | if (memcmp(RuleIdentifier.data()+1, "or_of_and_with_same_reg", 23) != 0) |
498 | break; |
499 | return 70; // "xor_of_and_with_same_reg" |
500 | } |
501 | break; |
502 | case 25: // 3 strings to match. |
503 | switch (RuleIdentifier[0]) { |
504 | default: break; |
505 | case 'b': // 2 strings to match. |
506 | if (memcmp(RuleIdentifier.data()+1, "itfield_extract_from_", 21) != 0) |
507 | break; |
508 | switch (RuleIdentifier[22]) { |
509 | default: break; |
510 | case 'a': // 1 string to match. |
511 | if (memcmp(RuleIdentifier.data()+23, "nd", 2) != 0) |
512 | break; |
513 | return 80; // "bitfield_extract_from_and" |
514 | case 's': // 1 string to match. |
515 | if (memcmp(RuleIdentifier.data()+23, "hr", 2) != 0) |
516 | break; |
517 | return 81; // "bitfield_extract_from_shr" |
518 | } |
519 | break; |
520 | case 'e': // 1 string to match. |
521 | if (memcmp(RuleIdentifier.data()+1, "xtract_vec_elt_build_vec", 24) != 0) |
522 | break; |
523 | return 5; // "extract_vec_elt_build_vec" |
524 | } |
525 | break; |
526 | case 26: // 3 strings to match. |
527 | switch (RuleIdentifier[0]) { |
528 | default: break; |
529 | case 'b': // 1 string to match. |
530 | if (memcmp(RuleIdentifier.data()+1, "inop_right_undef_to_undef", 25) != 0) |
531 | break; |
532 | return 14; // "binop_right_undef_to_undef" |
533 | case 'c': // 1 string to match. |
534 | if (memcmp(RuleIdentifier.data()+1, "ombine_indexed_load_store", 25) != 0) |
535 | break; |
536 | return 9; // "combine_indexed_load_store" |
537 | case 'f': // 1 string to match. |
538 | if (memcmp(RuleIdentifier.data()+1, "unnel_shift_from_or_shift", 25) != 0) |
539 | break; |
540 | return 77; // "funnel_shift_from_or_shift" |
541 | } |
542 | break; |
543 | case 28: // 3 strings to match. |
544 | switch (RuleIdentifier[0]) { |
545 | default: break; |
546 | case 'o': // 1 string to match. |
547 | if (memcmp(RuleIdentifier.data()+1, "pt_brcond_by_inverting_cond", 27) != 0) |
548 | break; |
549 | return 53; // "opt_brcond_by_inverting_cond" |
550 | case 'p': // 1 string to match. |
551 | if (memcmp(RuleIdentifier.data()+1, "ropagate_undef_shuffle_mask", 27) != 0) |
552 | break; |
553 | return 17; // "propagate_undef_shuffle_mask" |
554 | case 's': // 1 string to match. |
555 | if (memcmp(RuleIdentifier.data()+1, "hift_of_shifted_logic_chain", 27) != 0) |
556 | break; |
557 | return 73; // "shift_of_shifted_logic_chain" |
558 | } |
559 | break; |
560 | case 29: // 2 strings to match. |
561 | switch (RuleIdentifier[0]) { |
562 | default: break; |
563 | case 'b': // 1 string to match. |
564 | if (memcmp(RuleIdentifier.data()+1, "itfield_extract_from_shr_and", 28) != 0) |
565 | break; |
566 | return 82; // "bitfield_extract_from_shr_and" |
567 | case 'i': // 1 string to match. |
568 | if (memcmp(RuleIdentifier.data()+1, "cmp_to_true_false_known_bits", 28) != 0) |
569 | break; |
570 | return 49; // "icmp_to_true_false_known_bits" |
571 | } |
572 | break; |
573 | case 32: // 3 strings to match. |
574 | switch (RuleIdentifier[0]) { |
575 | default: break; |
576 | case 'b': // 1 string to match. |
577 | if (memcmp(RuleIdentifier.data()+1, "itfield_extract_from_sext_inreg", 31) != 0) |
578 | break; |
579 | return 79; // "bitfield_extract_from_sext_inreg" |
580 | case 'c': // 2 strings to match. |
581 | if (memcmp(RuleIdentifier.data()+1, "ombine_f", 8) != 0) |
582 | break; |
583 | switch (RuleIdentifier[9]) { |
584 | default: break; |
585 | case 'a': // 1 string to match. |
586 | if (memcmp(RuleIdentifier.data()+10, "dd_fmul_to_fmad_or_fma", 22) != 0) |
587 | break; |
588 | return 90; // "combine_fadd_fmul_to_fmad_or_fma" |
589 | case 's': // 1 string to match. |
590 | if (memcmp(RuleIdentifier.data()+10, "ub_fmul_to_fmad_or_fma", 22) != 0) |
591 | break; |
592 | return 94; // "combine_fsub_fmul_to_fmad_or_fma" |
593 | } |
594 | break; |
595 | } |
596 | break; |
597 | case 34: // 1 string to match. |
598 | if (memcmp(RuleIdentifier.data()+0, "extract_all_elts_from_build_vector", 34) != 0) |
599 | break; |
600 | return 6; // "extract_all_elts_from_build_vector" |
601 | case 36: // 3 strings to match. |
602 | switch (RuleIdentifier[0]) { |
603 | default: break; |
604 | case 'c': // 2 strings to match. |
605 | if (memcmp(RuleIdentifier.data()+1, "ombine_", 7) != 0) |
606 | break; |
607 | switch (RuleIdentifier[8]) { |
608 | default: break; |
609 | case 'f': // 1 string to match. |
610 | if (memcmp(RuleIdentifier.data()+9, "add_fma_fmul_to_fmad_or_fma", 27) != 0) |
611 | break; |
612 | return 92; // "combine_fadd_fma_fmul_to_fmad_or_fma" |
613 | case 'i': // 1 string to match. |
614 | if (memcmp(RuleIdentifier.data()+9, "nsert_vec_elts_build_vector", 27) != 0) |
615 | break; |
616 | return 4; // "combine_insert_vec_elts_build_vector" |
617 | } |
618 | break; |
619 | case 'i': // 1 string to match. |
620 | if (memcmp(RuleIdentifier.data()+1, "nsert_extract_vec_elt_out_of_bounds", 35) != 0) |
621 | break; |
622 | return 20; // "insert_extract_vec_elt_out_of_bounds" |
623 | } |
624 | break; |
625 | case 37: // 2 strings to match. |
626 | switch (RuleIdentifier[0]) { |
627 | default: break; |
628 | case 'c': // 1 string to match. |
629 | if (memcmp(RuleIdentifier.data()+1, "ombine_fsub_fneg_fmul_to_fmad_or_fma", 36) != 0) |
630 | break; |
631 | return 95; // "combine_fsub_fneg_fmul_to_fmad_or_fma" |
632 | case 'h': // 1 string to match. |
633 | if (memcmp(RuleIdentifier.data()+1, "oist_logic_op_with_same_opcode_hands", 36) != 0) |
634 | break; |
635 | return 34; // "hoist_logic_op_with_same_opcode_hands" |
636 | } |
637 | break; |
638 | case 38: // 2 strings to match. |
639 | if (memcmp(RuleIdentifier.data()+0, "combine_f", 9) != 0) |
640 | break; |
641 | switch (RuleIdentifier[9]) { |
642 | default: break; |
643 | case 'a': // 1 string to match. |
644 | if (memcmp(RuleIdentifier.data()+10, "dd_fpext_fmul_to_fmad_or_fma", 28) != 0) |
645 | break; |
646 | return 91; // "combine_fadd_fpext_fmul_to_fmad_or_fma" |
647 | case 's': // 1 string to match. |
648 | if (memcmp(RuleIdentifier.data()+10, "ub_fpext_fmul_to_fmad_or_fma", 28) != 0) |
649 | break; |
650 | return 96; // "combine_fsub_fpext_fmul_to_fmad_or_fma" |
651 | } |
652 | break; |
653 | case 42: // 1 string to match. |
654 | if (memcmp(RuleIdentifier.data()+0, "combine_fadd_fpext_fma_fmul_to_fmad_or_fma", 42) != 0) |
655 | break; |
656 | return 93; // "combine_fadd_fpext_fma_fmul_to_fmad_or_fma" |
657 | case 43: // 1 string to match. |
658 | if (memcmp(RuleIdentifier.data()+0, "combine_fsub_fpext_fneg_fmul_to_fmad_or_fma", 43) != 0) |
659 | break; |
660 | return 97; // "combine_fsub_fpext_fneg_fmul_to_fmad_or_fma" |
661 | } |
662 | #endif // ifndef NDEBUG |
663 | |
664 | return None; |
665 | } |
666 | static Optional<std::pair<uint64_t, uint64_t>> getRuleRangeForIdentifier(StringRef RuleIdentifier) { |
667 | std::pair<StringRef, StringRef> RangePair = RuleIdentifier.split('-'); |
668 | if (!RangePair.second.empty()) { |
669 | const auto First = getRuleIdxForIdentifier(RangePair.first); |
670 | const auto Last = getRuleIdxForIdentifier(RangePair.second); |
671 | if (!First || !Last) |
672 | return None; |
673 | if (First >= Last) |
674 | report_fatal_error("Beginning of range should be before end of range"); |
675 | return {{*First, *Last + 1}}; |
676 | } |
677 | if (RangePair.first == "*") { |
678 | return {{0, 102}}; |
679 | } |
680 | const auto I = getRuleIdxForIdentifier(RangePair.first); |
681 | if (!I) |
682 | return None; |
683 | return {{*I, *I + 1}}; |
684 | } |
685 | |
686 | bool AArch64GenPreLegalizerCombinerHelperRuleConfig::setRuleEnabled(StringRef RuleIdentifier) { |
687 | auto MaybeRange = getRuleRangeForIdentifier(RuleIdentifier); |
688 | if (!MaybeRange) |
689 | return false; |
690 | for (auto I = MaybeRange->first; I < MaybeRange->second; ++I) |
691 | DisabledRules.reset(I); |
692 | return true; |
693 | } |
694 | |
695 | bool AArch64GenPreLegalizerCombinerHelperRuleConfig::setRuleDisabled(StringRef RuleIdentifier) { |
696 | auto MaybeRange = getRuleRangeForIdentifier(RuleIdentifier); |
697 | if (!MaybeRange) |
698 | return false; |
699 | for (auto I = MaybeRange->first; I < MaybeRange->second; ++I) |
700 | DisabledRules.set(I); |
701 | return true; |
702 | } |
703 | |
704 | bool AArch64GenPreLegalizerCombinerHelperRuleConfig::isRuleDisabled(unsigned RuleID) const { |
705 | return DisabledRules.test(RuleID); |
706 | } |
707 | #endif // ifdef AARCH64PRELEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_H |
708 | |
709 | #ifdef AARCH64PRELEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_CPP |
710 | |
711 | std::vector<std::string> AArch64PreLegalizerCombinerHelperOption; |
712 | cl::list<std::string> AArch64PreLegalizerCombinerHelperDisableOption( |
713 | "aarch64prelegalizercombinerhelper-disable-rule", |
714 | cl::desc("Disable one or more combiner rules temporarily in the AArch64PreLegalizerCombinerHelper pass"), |
715 | cl::CommaSeparated, |
716 | cl::Hidden, |
717 | cl::cat(GICombinerOptionCategory), |
718 | cl::callback([](const std::string &Str) { |
719 | AArch64PreLegalizerCombinerHelperOption.push_back(Str); |
720 | })); |
721 | cl::list<std::string> AArch64PreLegalizerCombinerHelperOnlyEnableOption( |
722 | "aarch64prelegalizercombinerhelper-only-enable-rule", |
723 | cl::desc("Disable all rules in the AArch64PreLegalizerCombinerHelper pass then re-enable the specified ones"), |
724 | cl::Hidden, |
725 | cl::cat(GICombinerOptionCategory), |
726 | cl::callback([](const std::string &CommaSeparatedArg) { |
727 | StringRef Str = CommaSeparatedArg; |
728 | AArch64PreLegalizerCombinerHelperOption.push_back("*"); |
729 | do { |
730 | auto X = Str.split(","); |
731 | AArch64PreLegalizerCombinerHelperOption.push_back(("!" + X.first).str()); |
732 | Str = X.second; |
733 | } while (!Str.empty()); |
734 | })); |
735 | |
736 | bool AArch64GenPreLegalizerCombinerHelperRuleConfig::parseCommandLineOption() { |
737 | for (StringRef Identifier : AArch64PreLegalizerCombinerHelperOption) { |
738 | bool Enabled = Identifier.consume_front("!"); |
739 | if (Enabled && !setRuleEnabled(Identifier)) |
740 | return false; |
741 | if (!Enabled && !setRuleDisabled(Identifier)) |
742 | return false; |
743 | } |
744 | return true; |
745 | } |
746 | |
747 | bool AArch64GenPreLegalizerCombinerHelper::tryCombineAll( |
748 | GISelChangeObserver &Observer, |
749 | MachineInstr &MI, |
750 | MachineIRBuilder &B) const { |
751 | MachineBasicBlock *MBB = MI.getParent(); |
752 | MachineFunction *MF = MBB->getParent(); |
753 | MachineRegisterInfo &MRI = MF->getRegInfo(); |
754 | SmallVector<MachineInstr *, 8> MIs = {&MI}; |
755 | |
756 | (void)MBB; (void)MF; (void)MRI; (void)RuleConfig; |
757 | |
758 | // Match data |
759 | unsigned MatchData1; |
760 | std::pair<Register, bool> MatchData2; |
761 | SmallVector<Register, 4> MatchData4; |
762 | Register MatchData5; |
763 | SmallVector<std::pair<Register, MachineInstr*>> MatchData6; |
764 | PreferredTuple MatchData7; |
765 | std::function<void(MachineIRBuilder &)> MatchData8; |
766 | IndexedLoadStoreMatchInfo MatchData9; |
767 | std::function<void(MachineIRBuilder &)> MatchData19; |
768 | Register MatchData26; |
769 | Register MatchData27; |
770 | Register MatchData28; |
771 | Register MatchData29; |
772 | Register MatchData31; |
773 | MachineInstr* MatchData32; |
774 | std::tuple<Register, Register> MatchData33; |
775 | InstructionStepsMatchInfo MatchData34; |
776 | std::function<void(MachineIRBuilder &)> MatchData35; |
777 | PtrAddChain MatchData36; |
778 | std::tuple<Register, int64_t> MatchData37; |
779 | std::tuple<Register, unsigned> MatchData38; |
780 | RegisterImmPair MatchData39; |
781 | std::function<void(MachineIRBuilder &)> MatchData40; |
782 | unsigned MatchData42; |
783 | std::function<void(MachineIRBuilder &)> MatchData43; |
784 | Register MatchData44; |
785 | Register MatchData46; |
786 | Register MatchData48; |
787 | int64_t MatchData49; |
788 | std::function<void(MachineIRBuilder &)> MatchData50; |
789 | std::tuple<Register, unsigned> MatchData51; |
790 | SmallVector<Register, 4> MatchData52; |
791 | MachineInstr * MatchData53; |
792 | SmallVector<Register, 8> MatchData54; |
793 | Register MatchData55; |
794 | SmallVector<APInt, 8> MatchData56; |
795 | Register MatchData59; |
796 | std::pair<Register, unsigned> MatchData60; |
797 | std::pair<Register, Register> MatchData61; |
798 | Optional<APFloat> MatchData62; |
799 | APInt MatchData63; |
800 | std::function<void(MachineIRBuilder &)> MatchData64; |
801 | std::function<void(MachineIRBuilder &)> MatchData65; |
802 | std::function<void(MachineIRBuilder &)> MatchData66; |
803 | std::function<void(MachineIRBuilder &)> MatchData67; |
804 | std::function<void(MachineIRBuilder &)> MatchData68; |
805 | unsigned MatchData69; |
806 | std::pair<Register, Register> MatchData70; |
807 | RegisterImmPair MatchData72; |
808 | ShiftOfShiftedLogic MatchData73; |
809 | std::function<void(MachineIRBuilder &)> MatchData74; |
810 | MergeTruncStoresInfo MatchData75; |
811 | MachineInstr * MatchData76; |
812 | std::function<void(MachineIRBuilder &)> MatchData77; |
813 | std::function<void(MachineIRBuilder &)> MatchData79; |
814 | std::function<void(MachineIRBuilder &)> MatchData80; |
815 | std::function<void(MachineIRBuilder &)> MatchData81; |
816 | std::function<void(MachineIRBuilder &)> MatchData82; |
817 | APInt MatchData83; |
818 | std::function<void(MachineIRBuilder &)> MatchData84; |
819 | std::function<void(MachineIRBuilder &)> MatchData88; |
820 | std::function<void(MachineIRBuilder &)> MatchData89; |
821 | std::function<void(MachineIRBuilder &)> MatchData90; |
822 | std::function<void(MachineIRBuilder &)> MatchData91; |
823 | std::function<void(MachineIRBuilder &)> MatchData92; |
824 | std::function<void(MachineIRBuilder &)> MatchData93; |
825 | std::function<void(MachineIRBuilder &)> MatchData94; |
826 | std::function<void(MachineIRBuilder &)> MatchData95; |
827 | std::function<void(MachineIRBuilder &)> MatchData96; |
828 | std::function<void(MachineIRBuilder &)> MatchData97; |
829 | unsigned MatchData98; |
830 | Register MatchData100; |
831 | std::pair<uint64_t, uint64_t> MatchData101; |
832 | |
833 | int Partition = -1; |
834 | Partition = -1; |
835 | switch (MIs[0]->getOpcode()) { |
836 | case TargetOpcode::COPY: Partition = 0; break; |
837 | case TargetOpcode::G_MUL: Partition = 1; break; |
838 | case TargetOpcode::G_ADD: Partition = 2; break; |
839 | case TargetOpcode::G_INSERT_VECTOR_ELT: Partition = 3; break; |
840 | case TargetOpcode::G_EXTRACT_VECTOR_ELT: Partition = 4; break; |
841 | case TargetOpcode::G_BUILD_VECTOR: Partition = 5; break; |
842 | case TargetOpcode::G_LOAD: Partition = 6; break; |
843 | case TargetOpcode::G_SEXTLOAD: Partition = 7; break; |
844 | case TargetOpcode::G_ZEXTLOAD: Partition = 8; break; |
845 | case TargetOpcode::G_AND: Partition = 9; break; |
846 | case TargetOpcode::G_STORE: Partition = 10; break; |
847 | case TargetOpcode::G_UITOFP: Partition = 11; break; |
848 | case TargetOpcode::G_SITOFP: Partition = 12; break; |
849 | case TargetOpcode::G_OR: Partition = 13; break; |
850 | case TargetOpcode::G_SHL: Partition = 14; break; |
851 | case TargetOpcode::G_ASHR: Partition = 15; break; |
852 | case TargetOpcode::G_LSHR: Partition = 16; break; |
853 | case TargetOpcode::G_FPTOSI: Partition = 17; break; |
854 | case TargetOpcode::G_FPTOUI: Partition = 18; break; |
855 | case TargetOpcode::G_SUB: Partition = 19; break; |
856 | case TargetOpcode::G_XOR: Partition = 20; break; |
857 | case TargetOpcode::G_TRUNC: Partition = 21; break; |
858 | case TargetOpcode::G_SHUFFLE_VECTOR: Partition = 22; break; |
859 | case TargetOpcode::G_UNMERGE_VALUES: Partition = 23; break; |
860 | case TargetOpcode::G_SELECT: Partition = 24; break; |
861 | case TargetOpcode::G_PTR_ADD: Partition = 25; break; |
862 | case TargetOpcode::G_ROTL: Partition = 26; break; |
863 | case TargetOpcode::G_ROTR: Partition = 27; break; |
864 | case TargetOpcode::G_SDIV: Partition = 28; break; |
865 | case TargetOpcode::G_UDIV: Partition = 29; break; |
866 | case TargetOpcode::G_SREM: Partition = 30; break; |
867 | case TargetOpcode::G_UREM: Partition = 31; break; |
868 | case TargetOpcode::G_INTTOPTR: Partition = 32; break; |
869 | case TargetOpcode::G_PTRTOINT: Partition = 33; break; |
870 | case TargetOpcode::G_ANYEXT: Partition = 34; break; |
871 | case TargetOpcode::G_FNEG: Partition = 35; break; |
872 | case TargetOpcode::G_PHI: Partition = 36; break; |
873 | case TargetOpcode::G_SEXT_INREG: Partition = 37; break; |
874 | case TargetOpcode::G_ZEXT: Partition = 38; break; |
875 | case TargetOpcode::G_ICMP: Partition = 39; break; |
876 | case TargetOpcode::G_SEXT: Partition = 40; break; |
877 | case TargetOpcode::G_BR: Partition = 41; break; |
878 | case TargetOpcode::G_FABS: Partition = 42; break; |
879 | case TargetOpcode::G_MERGE_VALUES: Partition = 43; break; |
880 | case TargetOpcode::G_FPTRUNC: Partition = 44; break; |
881 | case TargetOpcode::G_FSQRT: Partition = 45; break; |
882 | case TargetOpcode::G_FLOG2: Partition = 46; break; |
883 | case TargetOpcode::G_UMULO: Partition = 47; break; |
884 | case TargetOpcode::G_SMULO: Partition = 48; break; |
885 | case TargetOpcode::G_UADDO: Partition = 49; break; |
886 | case TargetOpcode::G_SADDO: Partition = 50; break; |
887 | case TargetOpcode::G_UADDE: Partition = 51; break; |
888 | case TargetOpcode::G_SADDE: Partition = 52; break; |
889 | case TargetOpcode::G_USUBE: Partition = 53; break; |
890 | case TargetOpcode::G_SSUBE: Partition = 54; break; |
891 | case TargetOpcode::G_FMINNUM: Partition = 55; break; |
892 | case TargetOpcode::G_FMAXNUM: Partition = 56; break; |
893 | case TargetOpcode::G_FMINIMUM: Partition = 57; break; |
894 | case TargetOpcode::G_FMAXIMUM: Partition = 58; break; |
895 | case TargetOpcode::G_SSHLSAT: Partition = 59; break; |
896 | case TargetOpcode::G_USHLSAT: Partition = 60; break; |
897 | case TargetOpcode::G_FSHL: Partition = 61; break; |
898 | case TargetOpcode::G_FSHR: Partition = 62; break; |
899 | case TargetOpcode::G_UMULH: Partition = 63; break; |
900 | case TargetOpcode::G_FADD: Partition = 64; break; |
901 | case TargetOpcode::G_FSUB: Partition = 65; break; |
902 | case TargetOpcode::G_FMUL: Partition = 66; break; |
903 | case TargetOpcode::G_FDIV: Partition = 67; break; |
904 | case TargetOpcode::G_FMAD: Partition = 68; break; |
905 | case TargetOpcode::G_FMA: Partition = 69; break; |
906 | case TargetOpcode::G_SMIN: Partition = 70; break; |
907 | case TargetOpcode::G_SMAX: Partition = 71; break; |
908 | case TargetOpcode::G_UMIN: Partition = 72; break; |
909 | case TargetOpcode::G_UMAX: Partition = 73; break; |
910 | case TargetOpcode::G_FREM: Partition = 74; break; |
911 | case TargetOpcode::G_FCONSTANT: Partition = 75; break; |
912 | case TargetOpcode::G_GLOBAL_VALUE: Partition = 76; break; |
913 | } |
914 | // Default case but without conflicting with potential default case in selection. |
915 | if (Partition == -1) return false; |
916 | if (Partition == 0 /* TargetOpcode::COPY */) { |
917 | // Leaf name: copy_prop |
918 | // Rule: copy_prop |
919 | if (!RuleConfig->isRuleDisabled(0)) { |
920 | if (1 |
921 | && [&]() { |
922 | return Helper.matchCombineCopy(*MIs[0]); |
923 | return true; |
924 | }()) { |
925 | Helper.applyCombineCopy(*MIs[0]); |
926 | return true; |
927 | } |
928 | } |
929 | return false; |
930 | } |
931 | if (Partition == 1 /* TargetOpcode::G_MUL */) { |
932 | // Leaf name: mul_to_shl |
933 | // Rule: mul_to_shl |
934 | if (!RuleConfig->isRuleDisabled(1)) { |
935 | if (1 |
936 | && [&]() { |
937 | return Helper.matchCombineMulToShl(*MIs[0], MatchData1); |
938 | return true; |
939 | }()) { |
940 | Helper.applyCombineMulToShl(*MIs[0], MatchData1); |
941 | return true; |
942 | } |
943 | } |
944 | // Leaf name: mul_by_neg_one |
945 | // Rule: mul_by_neg_one |
946 | if (!RuleConfig->isRuleDisabled(3)) { |
947 | if (1 |
948 | && [&]() { |
949 | return Helper.matchConstantOp(MIs[0]->getOperand(2), -1); |
950 | return true; |
951 | }()) { |
952 | Helper.applyCombineMulByNegativeOne(*MIs[0]); |
953 | return true; |
954 | } |
955 | } |
956 | // Leaf name: undef_to_int_zero |
957 | // Rule: undef_to_int_zero |
958 | if (!RuleConfig->isRuleDisabled(11)) { |
959 | if (1 |
960 | && [&]() { |
961 | return Helper.matchAnyExplicitUseIsUndef(*MIs[0]); |
962 | return true; |
963 | }()) { |
964 | Helper.replaceInstWithConstant(*MIs[0], 0); |
965 | return true; |
966 | } |
967 | } |
968 | // Leaf name: binop_right_to_zero |
969 | // Rule: binop_right_to_zero |
970 | if (!RuleConfig->isRuleDisabled(25)) { |
971 | if (1 |
972 | && [&]() { |
973 | return Helper.matchOperandIsZero(*MIs[0], 2); |
974 | return true; |
975 | }()) { |
976 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 2); |
977 | return true; |
978 | } |
979 | } |
980 | // Leaf name: right_identity_one |
981 | // Rule: right_identity_one |
982 | if (!RuleConfig->isRuleDisabled(30)) { |
983 | if (1 |
984 | && [&]() { |
985 | return Helper.matchConstantOp(MIs[0]->getOperand(2), 1); |
986 | return true; |
987 | }()) { |
988 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
989 | return true; |
990 | } |
991 | } |
992 | // Leaf name: constant_fold |
993 | // Rule: constant_fold |
994 | if (!RuleConfig->isRuleDisabled(83)) { |
995 | if (1 |
996 | && [&]() { |
997 | return Helper.matchConstantFold(*MIs[0], MatchData83); |
998 | return true; |
999 | }()) { |
1000 | Helper.replaceInstWithConstant(*MIs[0], MatchData83); |
1001 | return true; |
1002 | } |
1003 | } |
1004 | return false; |
1005 | } |
1006 | if (Partition == 2 /* TargetOpcode::G_ADD */) { |
1007 | // Leaf name: add_p2i_to_ptradd |
1008 | // Rule: add_p2i_to_ptradd |
1009 | if (!RuleConfig->isRuleDisabled(2)) { |
1010 | if (1 |
1011 | && [&]() { |
1012 | return Helper.matchCombineAddP2IToPtrAdd(*MIs[0], MatchData2); |
1013 | return true; |
1014 | }()) { |
1015 | Helper.applyCombineAddP2IToPtrAdd(*MIs[0], MatchData2); |
1016 | return true; |
1017 | } |
1018 | } |
1019 | // Leaf name: propagate_undef_any_op |
1020 | // Rule: propagate_undef_any_op |
1021 | if (!RuleConfig->isRuleDisabled(15)) { |
1022 | if (1 |
1023 | && [&]() { |
1024 | return Helper.matchAnyExplicitUseIsUndef(*MIs[0]); |
1025 | return true; |
1026 | }()) { |
1027 | Helper.replaceInstWithUndef(*MIs[0]); |
1028 | return true; |
1029 | } |
1030 | } |
1031 | // Leaf name: right_identity_zero |
1032 | // Rule: right_identity_zero |
1033 | if (!RuleConfig->isRuleDisabled(22)) { |
1034 | if (1 |
1035 | && [&]() { |
1036 | return Helper.matchConstantOp(MIs[0]->getOperand(2), 0); |
1037 | return true; |
1038 | }()) { |
1039 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
1040 | return true; |
1041 | } |
1042 | } |
1043 | // Leaf name: add_sub_reg |
1044 | // Rule: add_sub_reg |
1045 | if (!RuleConfig->isRuleDisabled(31)) { |
1046 | if (1 |
1047 | && [&]() { |
1048 | return Helper.matchAddSubSameReg(*MIs[0], MatchData31); |
1049 | return true; |
1050 | }()) { |
1051 | return Helper.replaceSingleDefInstWithReg(*MIs[0], |
1052 | MatchData31); |
1053 | return true; |
1054 | } |
1055 | } |
1056 | // Leaf name: simplify_add_to_sub |
1057 | // Rule: simplify_add_to_sub |
1058 | if (!RuleConfig->isRuleDisabled(33)) { |
1059 | if (1 |
1060 | && [&]() { |
1061 | return Helper.matchSimplifyAddToSub(*MIs[0], MatchData33); |
1062 | return true; |
1063 | }()) { |
1064 | Helper.applySimplifyAddToSub(*MIs[0], MatchData33); |
1065 | return true; |
1066 | } |
1067 | } |
1068 | // Leaf name: constant_fold |
1069 | // Rule: constant_fold |
1070 | if (!RuleConfig->isRuleDisabled(83)) { |
1071 | if (1 |
1072 | && [&]() { |
1073 | return Helper.matchConstantFold(*MIs[0], MatchData83); |
1074 | return true; |
1075 | }()) { |
1076 | Helper.replaceInstWithConstant(*MIs[0], MatchData83); |
1077 | return true; |
1078 | } |
1079 | } |
1080 | // Leaf name: fold_binop_into_select |
1081 | // Rule: fold_binop_into_select |
1082 | if (!RuleConfig->isRuleDisabled(98)) { |
1083 | if (1 |
1084 | && [&]() { |
1085 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1086 | return true; |
1087 | }()) { |
1088 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1089 | return true; |
1090 | } |
1091 | } |
1092 | return false; |
1093 | } |
1094 | if (Partition == 3 /* TargetOpcode::G_INSERT_VECTOR_ELT */) { |
1095 | // Leaf name: combine_insert_vec_elts_build_vector |
1096 | // Rule: combine_insert_vec_elts_build_vector |
1097 | if (!RuleConfig->isRuleDisabled(4)) { |
1098 | if (1 |
1099 | && [&]() { |
1100 | return Helper.matchCombineInsertVecElts(*MIs[0], MatchData4); |
1101 | return true; |
1102 | }()) { |
1103 | Helper.applyCombineInsertVecElts(*MIs[0], MatchData4); |
1104 | return true; |
1105 | } |
1106 | } |
1107 | // Leaf name: insert_extract_vec_elt_out_of_bounds |
1108 | // Rule: insert_extract_vec_elt_out_of_bounds |
1109 | if (!RuleConfig->isRuleDisabled(20)) { |
1110 | if (1 |
1111 | && [&]() { |
1112 | return Helper.matchInsertExtractVecEltOutOfBounds(*MIs[0]); |
1113 | return true; |
1114 | }()) { |
1115 | Helper.replaceInstWithUndef(*MIs[0]); |
1116 | return true; |
1117 | } |
1118 | } |
1119 | return false; |
1120 | } |
1121 | if (Partition == 4 /* TargetOpcode::G_EXTRACT_VECTOR_ELT */) { |
1122 | // Leaf name: extract_vec_elt_build_vec |
1123 | // Rule: extract_vec_elt_build_vec |
1124 | if (!RuleConfig->isRuleDisabled(5)) { |
1125 | if (1 |
1126 | && [&]() { |
1127 | return Helper.matchExtractVecEltBuildVec(*MIs[0], MatchData5); |
1128 | return true; |
1129 | }()) { |
1130 | Helper.applyExtractVecEltBuildVec(*MIs[0], MatchData5); |
1131 | return true; |
1132 | } |
1133 | } |
1134 | // Leaf name: insert_extract_vec_elt_out_of_bounds |
1135 | // Rule: insert_extract_vec_elt_out_of_bounds |
1136 | if (!RuleConfig->isRuleDisabled(20)) { |
1137 | if (1 |
1138 | && [&]() { |
1139 | return Helper.matchInsertExtractVecEltOutOfBounds(*MIs[0]); |
1140 | return true; |
1141 | }()) { |
1142 | Helper.replaceInstWithUndef(*MIs[0]); |
1143 | return true; |
1144 | } |
1145 | } |
1146 | return false; |
1147 | } |
1148 | if (Partition == 5 /* TargetOpcode::G_BUILD_VECTOR */) { |
1149 | // Leaf name: extract_all_elts_from_build_vector |
1150 | // Rule: extract_all_elts_from_build_vector |
1151 | if (!RuleConfig->isRuleDisabled(6)) { |
1152 | if (1 |
1153 | && [&]() { |
1154 | return Helper.matchExtractAllEltsFromBuildVector(*MIs[0], MatchData6); |
1155 | return true; |
1156 | }()) { |
1157 | Helper.applyExtractAllEltsFromBuildVector(*MIs[0], MatchData6); |
1158 | return true; |
1159 | } |
1160 | } |
1161 | return false; |
1162 | } |
1163 | if (Partition == 6 /* TargetOpcode::G_LOAD */) { |
1164 | // Leaf name: extending_loads |
1165 | // Rule: extending_loads |
1166 | if (!RuleConfig->isRuleDisabled(7)) { |
1167 | if (1 |
1168 | && [&]() { |
1169 | return Helper.matchCombineExtendingLoads(*MIs[0], MatchData7); |
1170 | return true; |
1171 | }()) { |
1172 | Helper.applyCombineExtendingLoads(*MIs[0], MatchData7); |
1173 | return true; |
1174 | } |
1175 | } |
1176 | // Leaf name: combine_indexed_load_store |
1177 | // Rule: combine_indexed_load_store |
1178 | if (!RuleConfig->isRuleDisabled(9)) { |
1179 | if (1 |
1180 | && [&]() { |
1181 | return Helper.matchCombineIndexedLoadStore(*MIs[0], MatchData9); |
1182 | return true; |
1183 | }()) { |
1184 | Helper.applyCombineIndexedLoadStore(*MIs[0], MatchData9); |
1185 | return true; |
1186 | } |
1187 | } |
1188 | return false; |
1189 | } |
1190 | if (Partition == 7 /* TargetOpcode::G_SEXTLOAD */) { |
1191 | // Leaf name: extending_loads |
1192 | // Rule: extending_loads |
1193 | if (!RuleConfig->isRuleDisabled(7)) { |
1194 | if (1 |
1195 | && [&]() { |
1196 | return Helper.matchCombineExtendingLoads(*MIs[0], MatchData7); |
1197 | return true; |
1198 | }()) { |
1199 | Helper.applyCombineExtendingLoads(*MIs[0], MatchData7); |
1200 | return true; |
1201 | } |
1202 | } |
1203 | // Leaf name: combine_indexed_load_store |
1204 | // Rule: combine_indexed_load_store |
1205 | if (!RuleConfig->isRuleDisabled(9)) { |
1206 | if (1 |
1207 | && [&]() { |
1208 | return Helper.matchCombineIndexedLoadStore(*MIs[0], MatchData9); |
1209 | return true; |
1210 | }()) { |
1211 | Helper.applyCombineIndexedLoadStore(*MIs[0], MatchData9); |
1212 | return true; |
1213 | } |
1214 | } |
1215 | return false; |
1216 | } |
1217 | if (Partition == 8 /* TargetOpcode::G_ZEXTLOAD */) { |
1218 | // Leaf name: extending_loads |
1219 | // Rule: extending_loads |
1220 | if (!RuleConfig->isRuleDisabled(7)) { |
1221 | if (1 |
1222 | && [&]() { |
1223 | return Helper.matchCombineExtendingLoads(*MIs[0], MatchData7); |
1224 | return true; |
1225 | }()) { |
1226 | Helper.applyCombineExtendingLoads(*MIs[0], MatchData7); |
1227 | return true; |
1228 | } |
1229 | } |
1230 | // Leaf name: combine_indexed_load_store |
1231 | // Rule: combine_indexed_load_store |
1232 | if (!RuleConfig->isRuleDisabled(9)) { |
1233 | if (1 |
1234 | && [&]() { |
1235 | return Helper.matchCombineIndexedLoadStore(*MIs[0], MatchData9); |
1236 | return true; |
1237 | }()) { |
1238 | Helper.applyCombineIndexedLoadStore(*MIs[0], MatchData9); |
1239 | return true; |
1240 | } |
1241 | } |
1242 | return false; |
1243 | } |
1244 | if (Partition == 9 /* TargetOpcode::G_AND */) { |
1245 | // Leaf name: load_and_mask |
1246 | // Rule: load_and_mask |
1247 | if (!RuleConfig->isRuleDisabled(8)) { |
1248 | if (1 |
1249 | && [&]() { |
1250 | return Helper.matchCombineLoadWithAndMask(*MIs[0], MatchData8); |
1251 | return true; |
1252 | }()) { |
1253 | Helper.applyBuildFn(*MIs[0], MatchData8); |
1254 | return true; |
1255 | } |
1256 | } |
1257 | // Leaf name: undef_to_int_zero |
1258 | // Rule: undef_to_int_zero |
1259 | if (!RuleConfig->isRuleDisabled(11)) { |
1260 | if (1 |
1261 | && [&]() { |
1262 | return Helper.matchAnyExplicitUseIsUndef(*MIs[0]); |
1263 | return true; |
1264 | }()) { |
1265 | Helper.replaceInstWithConstant(*MIs[0], 0); |
1266 | return true; |
1267 | } |
1268 | } |
1269 | // Leaf name: binop_same_val |
1270 | // Rule: binop_same_val |
1271 | if (!RuleConfig->isRuleDisabled(23)) { |
1272 | if (1 |
1273 | && [&]() { |
1274 | return Helper.matchBinOpSameVal(*MIs[0]); |
1275 | return true; |
1276 | }()) { |
1277 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
1278 | return true; |
1279 | } |
1280 | } |
1281 | // Leaf name: hoist_logic_op_with_same_opcode_hands |
1282 | // Rule: hoist_logic_op_with_same_opcode_hands |
1283 | if (!RuleConfig->isRuleDisabled(34)) { |
1284 | if (1 |
1285 | && [&]() { |
1286 | return Helper.matchHoistLogicOpWithSameOpcodeHands(*MIs[0], MatchData34); |
1287 | return true; |
1288 | }()) { |
1289 | Helper.applyBuildInstructionSteps(*MIs[0], MatchData34); |
1290 | return true; |
1291 | } |
1292 | } |
1293 | // Leaf name: narrow_binop_feeding_and |
1294 | // Rule: narrow_binop_feeding_and |
1295 | if (!RuleConfig->isRuleDisabled(40)) { |
1296 | if (1 |
1297 | && [&]() { |
1298 | return Helper.matchNarrowBinopFeedingAnd(*MIs[0], MatchData40); |
1299 | return true; |
1300 | }()) { |
1301 | Helper.applyBuildFnNoErase(*MIs[0], MatchData40); |
1302 | return true; |
1303 | } |
1304 | } |
1305 | // Leaf name: redundant_and |
1306 | // Rule: redundant_and |
1307 | if (!RuleConfig->isRuleDisabled(44)) { |
1308 | if (1 |
1309 | && [&]() { |
1310 | return Helper.matchRedundantAnd(*MIs[0], MatchData44); |
1311 | return true; |
1312 | }()) { |
1313 | return Helper.replaceSingleDefInstWithReg(*MIs[0], MatchData44); |
1314 | return true; |
1315 | } |
1316 | } |
1317 | // Leaf name: overlapping_and |
1318 | // Rule: overlapping_and |
1319 | if (!RuleConfig->isRuleDisabled(64)) { |
1320 | if (1 |
1321 | && [&]() { |
1322 | return Helper.matchOverlappingAnd(*MIs[0], MatchData64); |
1323 | return true; |
1324 | }()) { |
1325 | Helper.applyBuildFn(*MIs[0], MatchData64); |
1326 | return true; |
1327 | } |
1328 | } |
1329 | // Leaf name: bitfield_extract_from_and |
1330 | // Rule: bitfield_extract_from_and |
1331 | if (!RuleConfig->isRuleDisabled(80)) { |
1332 | if (1 |
1333 | && [&]() { |
1334 | return Helper.matchBitfieldExtractFromAnd(*MIs[0], MatchData80); |
1335 | return true; |
1336 | }()) { |
1337 | Helper.applyBuildFn(*MIs[0], MatchData80); |
1338 | return true; |
1339 | } |
1340 | } |
1341 | // Leaf name: constant_fold |
1342 | // Rule: constant_fold |
1343 | if (!RuleConfig->isRuleDisabled(83)) { |
1344 | if (1 |
1345 | && [&]() { |
1346 | return Helper.matchConstantFold(*MIs[0], MatchData83); |
1347 | return true; |
1348 | }()) { |
1349 | Helper.replaceInstWithConstant(*MIs[0], MatchData83); |
1350 | return true; |
1351 | } |
1352 | } |
1353 | // Leaf name: and_or_disjoint_mask |
1354 | // Rule: and_or_disjoint_mask |
1355 | if (!RuleConfig->isRuleDisabled(89)) { |
1356 | if (1 |
1357 | && [&]() { |
1358 | return Helper.matchAndOrDisjointMask(*MIs[0], MatchData89); |
1359 | return true; |
1360 | }()) { |
1361 | Helper.applyBuildFnNoErase(*MIs[0], MatchData89); |
1362 | return true; |
1363 | } |
1364 | } |
1365 | // Leaf name: fold_binop_into_select |
1366 | // Rule: fold_binop_into_select |
1367 | if (!RuleConfig->isRuleDisabled(98)) { |
1368 | if (1 |
1369 | && [&]() { |
1370 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1371 | return true; |
1372 | }()) { |
1373 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1374 | return true; |
1375 | } |
1376 | } |
1377 | return false; |
1378 | } |
1379 | if (Partition == 10 /* TargetOpcode::G_STORE */) { |
1380 | // Leaf name: combine_indexed_load_store |
1381 | // Rule: combine_indexed_load_store |
1382 | if (!RuleConfig->isRuleDisabled(9)) { |
1383 | if (1 |
1384 | && [&]() { |
1385 | return Helper.matchCombineIndexedLoadStore(*MIs[0], MatchData9); |
1386 | return true; |
1387 | }()) { |
1388 | Helper.applyCombineIndexedLoadStore(*MIs[0], MatchData9); |
1389 | return true; |
1390 | } |
1391 | } |
1392 | // Leaf name: erase_undef_store |
1393 | // Rule: erase_undef_store |
1394 | if (!RuleConfig->isRuleDisabled(18)) { |
1395 | if (1 |
1396 | && [&]() { |
1397 | return Helper.matchUndefStore(*MIs[0]); |
1398 | return true; |
1399 | }()) { |
1400 | return Helper.eraseInst(*MIs[0]); |
1401 | return true; |
1402 | } |
1403 | } |
1404 | // Leaf name: truncstore_merge |
1405 | // Rule: truncstore_merge |
1406 | if (!RuleConfig->isRuleDisabled(75)) { |
1407 | if (1 |
1408 | && [&]() { |
1409 | return Helper.matchTruncStoreMerge(*MIs[0], MatchData75); |
1410 | return true; |
1411 | }()) { |
1412 | Helper.applyTruncStoreMerge(*MIs[0], MatchData75); |
1413 | return true; |
1414 | } |
1415 | } |
1416 | return false; |
1417 | } |
1418 | if (Partition == 11 /* TargetOpcode::G_UITOFP */) { |
1419 | // Leaf name: undef_to_fp_zero |
1420 | // Rule: undef_to_fp_zero |
1421 | if (!RuleConfig->isRuleDisabled(10)) { |
1422 | if (1 |
1423 | && [&]() { |
1424 | return Helper.matchAnyExplicitUseIsUndef(*MIs[0]); |
1425 | return true; |
1426 | }()) { |
1427 | Helper.replaceInstWithFConstant(*MIs[0], 0.0); |
1428 | return true; |
1429 | } |
1430 | } |
1431 | return false; |
1432 | } |
1433 | if (Partition == 12 /* TargetOpcode::G_SITOFP */) { |
1434 | // Leaf name: undef_to_fp_zero |
1435 | // Rule: undef_to_fp_zero |
1436 | if (!RuleConfig->isRuleDisabled(10)) { |
1437 | if (1 |
1438 | && [&]() { |
1439 | return Helper.matchAnyExplicitUseIsUndef(*MIs[0]); |
1440 | return true; |
1441 | }()) { |
1442 | Helper.replaceInstWithFConstant(*MIs[0], 0.0); |
1443 | return true; |
1444 | } |
1445 | } |
1446 | return false; |
1447 | } |
1448 | if (Partition == 13 /* TargetOpcode::G_OR */) { |
1449 | // Leaf name: undef_to_negative_one |
1450 | // Rule: undef_to_negative_one |
1451 | if (!RuleConfig->isRuleDisabled(12)) { |
1452 | if (1 |
1453 | && [&]() { |
1454 | return Helper.matchAnyExplicitUseIsUndef(*MIs[0]); |
1455 | return true; |
1456 | }()) { |
1457 | Helper.replaceInstWithConstant(*MIs[0], -1); |
1458 | return true; |
1459 | } |
1460 | } |
1461 | // Leaf name: right_identity_zero |
1462 | // Rule: right_identity_zero |
1463 | if (!RuleConfig->isRuleDisabled(22)) { |
1464 | if (1 |
1465 | && [&]() { |
1466 | return Helper.matchConstantOp(MIs[0]->getOperand(2), 0); |
1467 | return true; |
1468 | }()) { |
1469 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
1470 | return true; |
1471 | } |
1472 | } |
1473 | // Leaf name: binop_same_val |
1474 | // Rule: binop_same_val |
1475 | if (!RuleConfig->isRuleDisabled(23)) { |
1476 | if (1 |
1477 | && [&]() { |
1478 | return Helper.matchBinOpSameVal(*MIs[0]); |
1479 | return true; |
1480 | }()) { |
1481 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
1482 | return true; |
1483 | } |
1484 | } |
1485 | // Leaf name: hoist_logic_op_with_same_opcode_hands |
1486 | // Rule: hoist_logic_op_with_same_opcode_hands |
1487 | if (!RuleConfig->isRuleDisabled(34)) { |
1488 | if (1 |
1489 | && [&]() { |
1490 | return Helper.matchHoistLogicOpWithSameOpcodeHands(*MIs[0], MatchData34); |
1491 | return true; |
1492 | }()) { |
1493 | Helper.applyBuildInstructionSteps(*MIs[0], MatchData34); |
1494 | return true; |
1495 | } |
1496 | } |
1497 | // Leaf name: redundant_or |
1498 | // Rule: redundant_or |
1499 | if (!RuleConfig->isRuleDisabled(46)) { |
1500 | if (1 |
1501 | && [&]() { |
1502 | return Helper.matchRedundantOr(*MIs[0], MatchData46); |
1503 | return true; |
1504 | }()) { |
1505 | return Helper.replaceSingleDefInstWithReg(*MIs[0], MatchData46); |
1506 | return true; |
1507 | } |
1508 | } |
1509 | // Leaf name: load_or_combine |
1510 | // Rule: load_or_combine |
1511 | if (!RuleConfig->isRuleDisabled(74)) { |
1512 | if (1 |
1513 | && [&]() { |
1514 | return Helper.matchLoadOrCombine(*MIs[0], MatchData74); |
1515 | return true; |
1516 | }()) { |
1517 | Helper.applyBuildFn(*MIs[0], MatchData74); |
1518 | return true; |
1519 | } |
1520 | } |
1521 | // Leaf name: funnel_shift_from_or_shift |
1522 | // Rule: funnel_shift_from_or_shift |
1523 | if (!RuleConfig->isRuleDisabled(77)) { |
1524 | if (1 |
1525 | && [&]() { |
1526 | return Helper.matchOrShiftToFunnelShift(*MIs[0], MatchData77); |
1527 | return true; |
1528 | }()) { |
1529 | Helper.applyBuildFn(*MIs[0], MatchData77); |
1530 | return true; |
1531 | } |
1532 | } |
1533 | // Leaf name: constant_fold |
1534 | // Rule: constant_fold |
1535 | if (!RuleConfig->isRuleDisabled(83)) { |
1536 | if (1 |
1537 | && [&]() { |
1538 | return Helper.matchConstantFold(*MIs[0], MatchData83); |
1539 | return true; |
1540 | }()) { |
1541 | Helper.replaceInstWithConstant(*MIs[0], MatchData83); |
1542 | return true; |
1543 | } |
1544 | } |
1545 | // Leaf name: fold_binop_into_select |
1546 | // Rule: fold_binop_into_select |
1547 | if (!RuleConfig->isRuleDisabled(98)) { |
1548 | if (1 |
1549 | && [&]() { |
1550 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1551 | return true; |
1552 | }()) { |
1553 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1554 | return true; |
1555 | } |
1556 | } |
1557 | return false; |
1558 | } |
1559 | if (Partition == 14 /* TargetOpcode::G_SHL */) { |
1560 | // Leaf name: binop_left_undef_to_zero |
1561 | // Rule: binop_left_undef_to_zero |
1562 | if (!RuleConfig->isRuleDisabled(13)) { |
1563 | if (1 |
1564 | && [&]() { |
1565 | return Helper.matchOperandIsUndef(*MIs[0], 1); |
1566 | return true; |
1567 | }()) { |
1568 | Helper.replaceInstWithConstant(*MIs[0], 0); |
1569 | return true; |
1570 | } |
1571 | } |
1572 | // Leaf name: binop_right_undef_to_undef |
1573 | // Rule: binop_right_undef_to_undef |
1574 | if (!RuleConfig->isRuleDisabled(14)) { |
1575 | if (1 |
1576 | && [&]() { |
1577 | return Helper.matchOperandIsUndef(*MIs[0], 2); |
1578 | return true; |
1579 | }()) { |
1580 | Helper.replaceInstWithUndef(*MIs[0]); |
1581 | return true; |
1582 | } |
1583 | } |
1584 | // Leaf name: right_identity_zero |
1585 | // Rule: right_identity_zero |
1586 | if (!RuleConfig->isRuleDisabled(22)) { |
1587 | if (1 |
1588 | && [&]() { |
1589 | return Helper.matchConstantOp(MIs[0]->getOperand(2), 0); |
1590 | return true; |
1591 | }()) { |
1592 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
1593 | return true; |
1594 | } |
1595 | } |
1596 | // Leaf name: reduce_shl_of_extend |
1597 | // Rule: reduce_shl_of_extend |
1598 | if (!RuleConfig->isRuleDisabled(39)) { |
1599 | if (1 |
1600 | && [&]() { |
1601 | return Helper.matchCombineShlOfExtend(*MIs[0], MatchData39); |
1602 | return true; |
1603 | }()) { |
1604 | Helper.applyCombineShlOfExtend(*MIs[0], MatchData39); |
1605 | return true; |
1606 | } |
1607 | } |
1608 | // Leaf name: shift_immed_chain |
1609 | // Rule: shift_immed_chain |
1610 | if (!RuleConfig->isRuleDisabled(72)) { |
1611 | if (1 |
1612 | && [&]() { |
1613 | return Helper.matchShiftImmedChain(*MIs[0], MatchData72); |
1614 | return true; |
1615 | }()) { |
1616 | Helper.applyShiftImmedChain(*MIs[0], MatchData72); |
1617 | return true; |
1618 | } |
1619 | } |
1620 | // Leaf name: shift_of_shifted_logic_chain |
1621 | // Rule: shift_of_shifted_logic_chain |
1622 | if (!RuleConfig->isRuleDisabled(73)) { |
1623 | if (1 |
1624 | && [&]() { |
1625 | return Helper.matchShiftOfShiftedLogic(*MIs[0], MatchData73); |
1626 | return true; |
1627 | }()) { |
1628 | Helper.applyShiftOfShiftedLogic(*MIs[0], MatchData73); |
1629 | return true; |
1630 | } |
1631 | } |
1632 | // Leaf name: fold_binop_into_select |
1633 | // Rule: fold_binop_into_select |
1634 | if (!RuleConfig->isRuleDisabled(98)) { |
1635 | if (1 |
1636 | && [&]() { |
1637 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1638 | return true; |
1639 | }()) { |
1640 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1641 | return true; |
1642 | } |
1643 | } |
1644 | return false; |
1645 | } |
1646 | if (Partition == 15 /* TargetOpcode::G_ASHR */) { |
1647 | // Leaf name: binop_right_undef_to_undef |
1648 | // Rule: binop_right_undef_to_undef |
1649 | if (!RuleConfig->isRuleDisabled(14)) { |
1650 | if (1 |
1651 | && [&]() { |
1652 | return Helper.matchOperandIsUndef(*MIs[0], 2); |
1653 | return true; |
1654 | }()) { |
1655 | Helper.replaceInstWithUndef(*MIs[0]); |
1656 | return true; |
1657 | } |
1658 | } |
1659 | // Leaf name: right_identity_zero |
1660 | // Rule: right_identity_zero |
1661 | if (!RuleConfig->isRuleDisabled(22)) { |
1662 | if (1 |
1663 | && [&]() { |
1664 | return Helper.matchConstantOp(MIs[0]->getOperand(2), 0); |
1665 | return true; |
1666 | }()) { |
1667 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
1668 | return true; |
1669 | } |
1670 | } |
1671 | // Leaf name: shl_ashr_to_sext_inreg |
1672 | // Rule: shl_ashr_to_sext_inreg |
1673 | if (!RuleConfig->isRuleDisabled(37)) { |
1674 | if (1 |
1675 | && [&]() { |
1676 | return Helper.matchAshrShlToSextInreg(*MIs[0], MatchData37); |
1677 | return true; |
1678 | }()) { |
1679 | Helper.applyAshShlToSextInreg(*MIs[0], MatchData37); |
1680 | return true; |
1681 | } |
1682 | } |
1683 | // Leaf name: shift_immed_chain |
1684 | // Rule: shift_immed_chain |
1685 | if (!RuleConfig->isRuleDisabled(72)) { |
1686 | if (1 |
1687 | && [&]() { |
1688 | return Helper.matchShiftImmedChain(*MIs[0], MatchData72); |
1689 | return true; |
1690 | }()) { |
1691 | Helper.applyShiftImmedChain(*MIs[0], MatchData72); |
1692 | return true; |
1693 | } |
1694 | } |
1695 | // Leaf name: shift_of_shifted_logic_chain |
1696 | // Rule: shift_of_shifted_logic_chain |
1697 | if (!RuleConfig->isRuleDisabled(73)) { |
1698 | if (1 |
1699 | && [&]() { |
1700 | return Helper.matchShiftOfShiftedLogic(*MIs[0], MatchData73); |
1701 | return true; |
1702 | }()) { |
1703 | Helper.applyShiftOfShiftedLogic(*MIs[0], MatchData73); |
1704 | return true; |
1705 | } |
1706 | } |
1707 | // Leaf name: bitfield_extract_from_shr |
1708 | // Rule: bitfield_extract_from_shr |
1709 | if (!RuleConfig->isRuleDisabled(81)) { |
1710 | if (1 |
1711 | && [&]() { |
1712 | return Helper.matchBitfieldExtractFromShr(*MIs[0], MatchData81); |
1713 | return true; |
1714 | }()) { |
1715 | Helper.applyBuildFn(*MIs[0], MatchData81); |
1716 | return true; |
1717 | } |
1718 | } |
1719 | // Leaf name: bitfield_extract_from_shr_and |
1720 | // Rule: bitfield_extract_from_shr_and |
1721 | if (!RuleConfig->isRuleDisabled(82)) { |
1722 | if (1 |
1723 | && [&]() { |
1724 | return Helper.matchBitfieldExtractFromShrAnd(*MIs[0], MatchData82); |
1725 | return true; |
1726 | }()) { |
1727 | Helper.applyBuildFn(*MIs[0], MatchData82); |
1728 | return true; |
1729 | } |
1730 | } |
1731 | // Leaf name: fold_binop_into_select |
1732 | // Rule: fold_binop_into_select |
1733 | if (!RuleConfig->isRuleDisabled(98)) { |
1734 | if (1 |
1735 | && [&]() { |
1736 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1737 | return true; |
1738 | }()) { |
1739 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1740 | return true; |
1741 | } |
1742 | } |
1743 | return false; |
1744 | } |
1745 | if (Partition == 16 /* TargetOpcode::G_LSHR */) { |
1746 | // Leaf name: binop_right_undef_to_undef |
1747 | // Rule: binop_right_undef_to_undef |
1748 | if (!RuleConfig->isRuleDisabled(14)) { |
1749 | if (1 |
1750 | && [&]() { |
1751 | return Helper.matchOperandIsUndef(*MIs[0], 2); |
1752 | return true; |
1753 | }()) { |
1754 | Helper.replaceInstWithUndef(*MIs[0]); |
1755 | return true; |
1756 | } |
1757 | } |
1758 | // Leaf name: right_identity_zero |
1759 | // Rule: right_identity_zero |
1760 | if (!RuleConfig->isRuleDisabled(22)) { |
1761 | if (1 |
1762 | && [&]() { |
1763 | return Helper.matchConstantOp(MIs[0]->getOperand(2), 0); |
1764 | return true; |
1765 | }()) { |
1766 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
1767 | return true; |
1768 | } |
1769 | } |
1770 | // Leaf name: shift_immed_chain |
1771 | // Rule: shift_immed_chain |
1772 | if (!RuleConfig->isRuleDisabled(72)) { |
1773 | if (1 |
1774 | && [&]() { |
1775 | return Helper.matchShiftImmedChain(*MIs[0], MatchData72); |
1776 | return true; |
1777 | }()) { |
1778 | Helper.applyShiftImmedChain(*MIs[0], MatchData72); |
1779 | return true; |
1780 | } |
1781 | } |
1782 | // Leaf name: shift_of_shifted_logic_chain |
1783 | // Rule: shift_of_shifted_logic_chain |
1784 | if (!RuleConfig->isRuleDisabled(73)) { |
1785 | if (1 |
1786 | && [&]() { |
1787 | return Helper.matchShiftOfShiftedLogic(*MIs[0], MatchData73); |
1788 | return true; |
1789 | }()) { |
1790 | Helper.applyShiftOfShiftedLogic(*MIs[0], MatchData73); |
1791 | return true; |
1792 | } |
1793 | } |
1794 | // Leaf name: bitfield_extract_from_shr |
1795 | // Rule: bitfield_extract_from_shr |
1796 | if (!RuleConfig->isRuleDisabled(81)) { |
1797 | if (1 |
1798 | && [&]() { |
1799 | return Helper.matchBitfieldExtractFromShr(*MIs[0], MatchData81); |
1800 | return true; |
1801 | }()) { |
1802 | Helper.applyBuildFn(*MIs[0], MatchData81); |
1803 | return true; |
1804 | } |
1805 | } |
1806 | // Leaf name: bitfield_extract_from_shr_and |
1807 | // Rule: bitfield_extract_from_shr_and |
1808 | if (!RuleConfig->isRuleDisabled(82)) { |
1809 | if (1 |
1810 | && [&]() { |
1811 | return Helper.matchBitfieldExtractFromShrAnd(*MIs[0], MatchData82); |
1812 | return true; |
1813 | }()) { |
1814 | Helper.applyBuildFn(*MIs[0], MatchData82); |
1815 | return true; |
1816 | } |
1817 | } |
1818 | // Leaf name: fold_binop_into_select |
1819 | // Rule: fold_binop_into_select |
1820 | if (!RuleConfig->isRuleDisabled(98)) { |
1821 | if (1 |
1822 | && [&]() { |
1823 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1824 | return true; |
1825 | }()) { |
1826 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1827 | return true; |
1828 | } |
1829 | } |
1830 | return false; |
1831 | } |
1832 | if (Partition == 17 /* TargetOpcode::G_FPTOSI */) { |
1833 | // Leaf name: propagate_undef_any_op |
1834 | // Rule: propagate_undef_any_op |
1835 | if (!RuleConfig->isRuleDisabled(15)) { |
1836 | if (1 |
1837 | && [&]() { |
1838 | return Helper.matchAnyExplicitUseIsUndef(*MIs[0]); |
1839 | return true; |
1840 | }()) { |
1841 | Helper.replaceInstWithUndef(*MIs[0]); |
1842 | return true; |
1843 | } |
1844 | } |
1845 | return false; |
1846 | } |
1847 | if (Partition == 18 /* TargetOpcode::G_FPTOUI */) { |
1848 | // Leaf name: propagate_undef_any_op |
1849 | // Rule: propagate_undef_any_op |
1850 | if (!RuleConfig->isRuleDisabled(15)) { |
1851 | if (1 |
1852 | && [&]() { |
1853 | return Helper.matchAnyExplicitUseIsUndef(*MIs[0]); |
1854 | return true; |
1855 | }()) { |
1856 | Helper.replaceInstWithUndef(*MIs[0]); |
1857 | return true; |
1858 | } |
1859 | } |
1860 | return false; |
1861 | } |
1862 | if (Partition == 19 /* TargetOpcode::G_SUB */) { |
1863 | // Leaf name: propagate_undef_any_op |
1864 | // Rule: propagate_undef_any_op |
1865 | if (!RuleConfig->isRuleDisabled(15)) { |
1866 | if (1 |
1867 | && [&]() { |
1868 | return Helper.matchAnyExplicitUseIsUndef(*MIs[0]); |
1869 | return true; |
1870 | }()) { |
1871 | Helper.replaceInstWithUndef(*MIs[0]); |
1872 | return true; |
1873 | } |
1874 | } |
1875 | // Leaf name: right_identity_zero |
1876 | // Rule: right_identity_zero |
1877 | if (!RuleConfig->isRuleDisabled(22)) { |
1878 | if (1 |
1879 | && [&]() { |
1880 | return Helper.matchConstantOp(MIs[0]->getOperand(2), 0); |
1881 | return true; |
1882 | }()) { |
1883 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
1884 | return true; |
1885 | } |
1886 | } |
1887 | // Leaf name: constant_fold |
1888 | // Rule: constant_fold |
1889 | if (!RuleConfig->isRuleDisabled(83)) { |
1890 | if (1 |
1891 | && [&]() { |
1892 | return Helper.matchConstantFold(*MIs[0], MatchData83); |
1893 | return true; |
1894 | }()) { |
1895 | Helper.replaceInstWithConstant(*MIs[0], MatchData83); |
1896 | return true; |
1897 | } |
1898 | } |
1899 | // Leaf name: fold_binop_into_select |
1900 | // Rule: fold_binop_into_select |
1901 | if (!RuleConfig->isRuleDisabled(98)) { |
1902 | if (1 |
1903 | && [&]() { |
1904 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1905 | return true; |
1906 | }()) { |
1907 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1908 | return true; |
1909 | } |
1910 | } |
1911 | return false; |
1912 | } |
1913 | if (Partition == 20 /* TargetOpcode::G_XOR */) { |
1914 | // Leaf name: propagate_undef_any_op |
1915 | // Rule: propagate_undef_any_op |
1916 | if (!RuleConfig->isRuleDisabled(15)) { |
1917 | if (1 |
1918 | && [&]() { |
1919 | return Helper.matchAnyExplicitUseIsUndef(*MIs[0]); |
1920 | return true; |
1921 | }()) { |
1922 | Helper.replaceInstWithUndef(*MIs[0]); |
1923 | return true; |
1924 | } |
1925 | } |
1926 | // Leaf name: right_identity_zero |
1927 | // Rule: right_identity_zero |
1928 | if (!RuleConfig->isRuleDisabled(22)) { |
1929 | if (1 |
1930 | && [&]() { |
1931 | return Helper.matchConstantOp(MIs[0]->getOperand(2), 0); |
1932 | return true; |
1933 | }()) { |
1934 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
1935 | return true; |
1936 | } |
1937 | } |
1938 | // Leaf name: hoist_logic_op_with_same_opcode_hands |
1939 | // Rule: hoist_logic_op_with_same_opcode_hands |
1940 | if (!RuleConfig->isRuleDisabled(34)) { |
1941 | if (1 |
1942 | && [&]() { |
1943 | return Helper.matchHoistLogicOpWithSameOpcodeHands(*MIs[0], MatchData34); |
1944 | return true; |
1945 | }()) { |
1946 | Helper.applyBuildInstructionSteps(*MIs[0], MatchData34); |
1947 | return true; |
1948 | } |
1949 | } |
1950 | // Leaf name: not_cmp_fold |
1951 | // Rule: not_cmp_fold |
1952 | if (!RuleConfig->isRuleDisabled(52)) { |
1953 | if (1 |
1954 | && [&]() { |
1955 | return Helper.matchNotCmp(*MIs[0], MatchData52); |
1956 | return true; |
1957 | }()) { |
1958 | Helper.applyNotCmp(*MIs[0], MatchData52); |
1959 | return true; |
1960 | } |
1961 | } |
1962 | // Leaf name: xor_of_and_with_same_reg |
1963 | // Rule: xor_of_and_with_same_reg |
1964 | if (!RuleConfig->isRuleDisabled(70)) { |
1965 | if (1 |
1966 | && [&]() { |
1967 | return Helper.matchXorOfAndWithSameReg(*MIs[0], MatchData70); |
1968 | return true; |
1969 | }()) { |
1970 | Helper.applyXorOfAndWithSameReg(*MIs[0], MatchData70); |
1971 | return true; |
1972 | } |
1973 | } |
1974 | // Leaf name: constant_fold |
1975 | // Rule: constant_fold |
1976 | if (!RuleConfig->isRuleDisabled(83)) { |
1977 | if (1 |
1978 | && [&]() { |
1979 | return Helper.matchConstantFold(*MIs[0], MatchData83); |
1980 | return true; |
1981 | }()) { |
1982 | Helper.replaceInstWithConstant(*MIs[0], MatchData83); |
1983 | return true; |
1984 | } |
1985 | } |
1986 | // Leaf name: fold_binop_into_select |
1987 | // Rule: fold_binop_into_select |
1988 | if (!RuleConfig->isRuleDisabled(98)) { |
1989 | if (1 |
1990 | && [&]() { |
1991 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1992 | return true; |
1993 | }()) { |
1994 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
1995 | return true; |
1996 | } |
1997 | } |
1998 | return false; |
1999 | } |
2000 | if (Partition == 21 /* TargetOpcode::G_TRUNC */) { |
2001 | // Leaf name: propagate_undef_any_op |
2002 | // Rule: propagate_undef_any_op |
2003 | if (!RuleConfig->isRuleDisabled(15)) { |
2004 | if (1 |
2005 | && [&]() { |
2006 | return Helper.matchAnyExplicitUseIsUndef(*MIs[0]); |
2007 | return true; |
2008 | }()) { |
2009 | Helper.replaceInstWithUndef(*MIs[0]); |
2010 | return true; |
2011 | } |
2012 | } |
2013 | // Leaf name: trunc_ext_fold |
2014 | // Rule: trunc_ext_fold |
2015 | if (!RuleConfig->isRuleDisabled(60)) { |
2016 | if (1 |
2017 | && [&]() { |
2018 | return Helper.matchCombineTruncOfExt(*MIs[0], MatchData60); |
2019 | return true; |
2020 | }()) { |
2021 | Helper.applyCombineTruncOfExt(*MIs[0], MatchData60); |
2022 | return true; |
2023 | } |
2024 | } |
2025 | // Leaf name: trunc_shl |
2026 | // Rule: trunc_shl |
2027 | if (!RuleConfig->isRuleDisabled(61)) { |
2028 | if (1 |
2029 | && [&]() { |
2030 | return Helper.matchCombineTruncOfShl(*MIs[0], MatchData61); |
2031 | return true; |
2032 | }()) { |
2033 | Helper.applyCombineTruncOfShl(*MIs[0], MatchData61); |
2034 | return true; |
2035 | } |
2036 | } |
2037 | return false; |
2038 | } |
2039 | if (Partition == 22 /* TargetOpcode::G_SHUFFLE_VECTOR */) { |
2040 | // Leaf name: propagate_undef_all_ops |
2041 | // Rule: propagate_undef_all_ops |
2042 | if (!RuleConfig->isRuleDisabled(16)) { |
2043 | if (1 |
2044 | && [&]() { |
2045 | return Helper.matchAllExplicitUsesAreUndef(*MIs[0]); |
2046 | return true; |
2047 | }()) { |
2048 | Helper.replaceInstWithUndef(*MIs[0]); |
2049 | return true; |
2050 | } |
2051 | } |
2052 | // Leaf name: propagate_undef_shuffle_mask |
2053 | // Rule: propagate_undef_shuffle_mask |
2054 | if (!RuleConfig->isRuleDisabled(17)) { |
2055 | if (1 |
2056 | && [&]() { |
2057 | return Helper.matchUndefShuffleVectorMask(*MIs[0]); |
2058 | return true; |
2059 | }()) { |
2060 | Helper.replaceInstWithUndef(*MIs[0]); |
2061 | return true; |
2062 | } |
2063 | } |
2064 | return false; |
2065 | } |
2066 | if (Partition == 23 /* TargetOpcode::G_UNMERGE_VALUES */) { |
2067 | // Leaf name: unmerge_undef |
2068 | // Rule: unmerge_undef |
2069 | if (!RuleConfig->isRuleDisabled(19)) { |
2070 | if (1 |
2071 | && [&]() { |
2072 | return Helper.matchCombineUnmergeUndef(*MIs[0], MatchData19); |
2073 | return true; |
2074 | }()) { |
2075 | Helper.applyBuildFn(*MIs[0], MatchData19); |
2076 | return true; |
2077 | } |
2078 | } |
2079 | // Leaf name: unmerge_merge |
2080 | // Rule: unmerge_merge |
2081 | if (!RuleConfig->isRuleDisabled(54)) { |
2082 | if (1 |
2083 | && [&]() { |
2084 | return Helper.matchCombineUnmergeMergeToPlainValues(*MIs[0], MatchData54); |
2085 | return true; |
2086 | }()) { |
2087 | Helper.applyCombineUnmergeMergeToPlainValues(*MIs[0], MatchData54); |
2088 | return true; |
2089 | } |
2090 | } |
2091 | // Leaf name: unmerge_cst |
2092 | // Rule: unmerge_cst |
2093 | if (!RuleConfig->isRuleDisabled(56)) { |
2094 | if (1 |
2095 | && [&]() { |
2096 | return Helper.matchCombineUnmergeConstant(*MIs[0], MatchData56); |
2097 | return true; |
2098 | }()) { |
2099 | Helper.applyCombineUnmergeConstant(*MIs[0], MatchData56); |
2100 | return true; |
2101 | } |
2102 | } |
2103 | // Leaf name: unmerge_dead_to_trunc |
2104 | // Rule: unmerge_dead_to_trunc |
2105 | if (!RuleConfig->isRuleDisabled(57)) { |
2106 | if (1 |
2107 | && [&]() { |
2108 | return Helper.matchCombineUnmergeWithDeadLanesToTrunc(*MIs[0]); |
2109 | return true; |
2110 | }()) { |
2111 | Helper.applyCombineUnmergeWithDeadLanesToTrunc(*MIs[0]); |
2112 | return true; |
2113 | } |
2114 | } |
2115 | // Leaf name: unmerge_zext_to_zext |
2116 | // Rule: unmerge_zext_to_zext |
2117 | if (!RuleConfig->isRuleDisabled(58)) { |
2118 | if (1 |
2119 | && [&]() { |
2120 | return Helper.matchCombineUnmergeZExtToZExt(*MIs[0]); |
2121 | return true; |
2122 | }()) { |
2123 | Helper.applyCombineUnmergeZExtToZExt(*MIs[0]); |
2124 | return true; |
2125 | } |
2126 | } |
2127 | return false; |
2128 | } |
2129 | if (Partition == 24 /* TargetOpcode::G_SELECT */) { |
2130 | // Leaf name: select_same_val |
2131 | // Rule: select_same_val |
2132 | if (!RuleConfig->isRuleDisabled(21)) { |
2133 | if (1 |
2134 | && [&]() { |
2135 | return Helper.matchSelectSameVal(*MIs[0]); |
2136 | return true; |
2137 | }()) { |
2138 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 2); |
2139 | return true; |
2140 | } |
2141 | } |
2142 | // Leaf name: select_undef_cmp |
2143 | // Rule: select_undef_cmp |
2144 | if (!RuleConfig->isRuleDisabled(41)) { |
2145 | if (1 |
2146 | && [&]() { |
2147 | return Helper.matchUndefSelectCmp(*MIs[0]); |
2148 | return true; |
2149 | }()) { |
2150 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 2); |
2151 | return true; |
2152 | } |
2153 | } |
2154 | // Leaf name: select_constant_cmp |
2155 | // Rule: select_constant_cmp |
2156 | if (!RuleConfig->isRuleDisabled(42)) { |
2157 | if (1 |
2158 | && [&]() { |
2159 | return Helper.matchConstantSelectCmp(*MIs[0], MatchData42); |
2160 | return true; |
2161 | }()) { |
2162 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], MatchData42); |
2163 | return true; |
2164 | } |
2165 | } |
2166 | // Leaf name: select_to_logical |
2167 | // Rule: select_to_logical |
2168 | if (!RuleConfig->isRuleDisabled(43)) { |
2169 | if (1 |
2170 | && [&]() { |
2171 | return Helper.matchSelectToLogical(*MIs[0], MatchData43); |
2172 | return true; |
2173 | }()) { |
2174 | Helper.applyBuildFn(*MIs[0], MatchData43); |
2175 | return true; |
2176 | } |
2177 | } |
2178 | return false; |
2179 | } |
2180 | if (Partition == 25 /* TargetOpcode::G_PTR_ADD */) { |
2181 | // Leaf name: right_identity_zero |
2182 | // Rule: right_identity_zero |
2183 | if (!RuleConfig->isRuleDisabled(22)) { |
2184 | if (1 |
2185 | && [&]() { |
2186 | return Helper.matchConstantOp(MIs[0]->getOperand(2), 0); |
2187 | return true; |
2188 | }()) { |
2189 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
2190 | return true; |
2191 | } |
2192 | } |
2193 | // Leaf name: reassoc_ptradd |
2194 | // Rule: reassoc_ptradd |
2195 | if (!RuleConfig->isRuleDisabled(35)) { |
2196 | if (1 |
2197 | && [&]() { |
2198 | return Helper.matchReassocPtrAdd(*MIs[0], MatchData35); |
2199 | return true; |
2200 | }()) { |
2201 | Helper.applyBuildFnNoErase(*MIs[0], MatchData35); |
2202 | return true; |
2203 | } |
2204 | } |
2205 | // Leaf name: ptr_add_immed_chain |
2206 | // Rule: ptr_add_immed_chain |
2207 | if (!RuleConfig->isRuleDisabled(36)) { |
2208 | if (1 |
2209 | && [&]() { |
2210 | return Helper.matchPtrAddImmedChain(*MIs[0], MatchData36); |
2211 | return true; |
2212 | }()) { |
2213 | Helper.applyPtrAddImmedChain(*MIs[0], MatchData36); |
2214 | return true; |
2215 | } |
2216 | } |
2217 | // Leaf name: const_ptradd_to_i2p |
2218 | // Rule: const_ptradd_to_i2p |
2219 | if (!RuleConfig->isRuleDisabled(63)) { |
2220 | if (1 |
2221 | && [&]() { |
2222 | return Helper.matchCombineConstPtrAddToI2P(*MIs[0], MatchData63); |
2223 | return true; |
2224 | }()) { |
2225 | Helper.applyCombineConstPtrAddToI2P(*MIs[0], MatchData63); |
2226 | return true; |
2227 | } |
2228 | } |
2229 | // Leaf name: ptr_add_with_zero |
2230 | // Rule: ptr_add_with_zero |
2231 | if (!RuleConfig->isRuleDisabled(71)) { |
2232 | if (1 |
2233 | && [&]() { |
2234 | return Helper.matchPtrAddZero(*MIs[0]); |
2235 | return true; |
2236 | }()) { |
2237 | Helper.applyPtrAddZero(*MIs[0]); |
2238 | return true; |
2239 | } |
2240 | } |
2241 | // Leaf name: fold_binop_into_select |
2242 | // Rule: fold_binop_into_select |
2243 | if (!RuleConfig->isRuleDisabled(98)) { |
2244 | if (1 |
2245 | && [&]() { |
2246 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
2247 | return true; |
2248 | }()) { |
2249 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
2250 | return true; |
2251 | } |
2252 | } |
2253 | return false; |
2254 | } |
2255 | if (Partition == 26 /* TargetOpcode::G_ROTL */) { |
2256 | // Leaf name: right_identity_zero |
2257 | // Rule: right_identity_zero |
2258 | if (!RuleConfig->isRuleDisabled(22)) { |
2259 | if (1 |
2260 | && [&]() { |
2261 | return Helper.matchConstantOp(MIs[0]->getOperand(2), 0); |
2262 | return true; |
2263 | }()) { |
2264 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
2265 | return true; |
2266 | } |
2267 | } |
2268 | return false; |
2269 | } |
2270 | if (Partition == 27 /* TargetOpcode::G_ROTR */) { |
2271 | // Leaf name: right_identity_zero |
2272 | // Rule: right_identity_zero |
2273 | if (!RuleConfig->isRuleDisabled(22)) { |
2274 | if (1 |
2275 | && [&]() { |
2276 | return Helper.matchConstantOp(MIs[0]->getOperand(2), 0); |
2277 | return true; |
2278 | }()) { |
2279 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
2280 | return true; |
2281 | } |
2282 | } |
2283 | return false; |
2284 | } |
2285 | if (Partition == 28 /* TargetOpcode::G_SDIV */) { |
2286 | // Leaf name: binop_left_to_zero |
2287 | // Rule: binop_left_to_zero |
2288 | if (!RuleConfig->isRuleDisabled(24)) { |
2289 | if (1 |
2290 | && [&]() { |
2291 | return Helper.matchOperandIsZero(*MIs[0], 1); |
2292 | return true; |
2293 | }()) { |
2294 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
2295 | return true; |
2296 | } |
2297 | } |
2298 | // Leaf name: div_rem_to_divrem |
2299 | // Rule: div_rem_to_divrem |
2300 | if (!RuleConfig->isRuleDisabled(76)) { |
2301 | if (1 |
2302 | && [&]() { |
2303 | return Helper.matchCombineDivRem(*MIs[0], MatchData76); |
2304 | return true; |
2305 | }()) { |
2306 | Helper.applyCombineDivRem(*MIs[0], MatchData76); |
2307 | return true; |
2308 | } |
2309 | } |
2310 | // Leaf name: sdiv_by_const |
2311 | // Rule: sdiv_by_const |
2312 | if (!RuleConfig->isRuleDisabled(86)) { |
2313 | if (1 |
2314 | && [&]() { |
2315 | return Helper.matchSDivByConst(*MIs[0]); |
2316 | return true; |
2317 | }()) { |
2318 | Helper.applySDivByConst(*MIs[0]); |
2319 | return true; |
2320 | } |
2321 | } |
2322 | // Leaf name: fold_binop_into_select |
2323 | // Rule: fold_binop_into_select |
2324 | if (!RuleConfig->isRuleDisabled(98)) { |
2325 | if (1 |
2326 | && [&]() { |
2327 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
2328 | return true; |
2329 | }()) { |
2330 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
2331 | return true; |
2332 | } |
2333 | } |
2334 | return false; |
2335 | } |
2336 | if (Partition == 29 /* TargetOpcode::G_UDIV */) { |
2337 | // Leaf name: binop_left_to_zero |
2338 | // Rule: binop_left_to_zero |
2339 | if (!RuleConfig->isRuleDisabled(24)) { |
2340 | if (1 |
2341 | && [&]() { |
2342 | return Helper.matchOperandIsZero(*MIs[0], 1); |
2343 | return true; |
2344 | }()) { |
2345 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
2346 | return true; |
2347 | } |
2348 | } |
2349 | // Leaf name: div_rem_to_divrem |
2350 | // Rule: div_rem_to_divrem |
2351 | if (!RuleConfig->isRuleDisabled(76)) { |
2352 | if (1 |
2353 | && [&]() { |
2354 | return Helper.matchCombineDivRem(*MIs[0], MatchData76); |
2355 | return true; |
2356 | }()) { |
2357 | Helper.applyCombineDivRem(*MIs[0], MatchData76); |
2358 | return true; |
2359 | } |
2360 | } |
2361 | // Leaf name: udiv_by_const |
2362 | // Rule: udiv_by_const |
2363 | if (!RuleConfig->isRuleDisabled(85)) { |
2364 | if (1 |
2365 | && [&]() { |
2366 | return Helper.matchUDivByConst(*MIs[0]); |
2367 | return true; |
2368 | }()) { |
2369 | Helper.applyUDivByConst(*MIs[0]); |
2370 | return true; |
2371 | } |
2372 | } |
2373 | // Leaf name: fold_binop_into_select |
2374 | // Rule: fold_binop_into_select |
2375 | if (!RuleConfig->isRuleDisabled(98)) { |
2376 | if (1 |
2377 | && [&]() { |
2378 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
2379 | return true; |
2380 | }()) { |
2381 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
2382 | return true; |
2383 | } |
2384 | } |
2385 | return false; |
2386 | } |
2387 | if (Partition == 30 /* TargetOpcode::G_SREM */) { |
2388 | // Leaf name: binop_left_to_zero |
2389 | // Rule: binop_left_to_zero |
2390 | if (!RuleConfig->isRuleDisabled(24)) { |
2391 | if (1 |
2392 | && [&]() { |
2393 | return Helper.matchOperandIsZero(*MIs[0], 1); |
2394 | return true; |
2395 | }()) { |
2396 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
2397 | return true; |
2398 | } |
2399 | } |
2400 | // Leaf name: div_rem_to_divrem |
2401 | // Rule: div_rem_to_divrem |
2402 | if (!RuleConfig->isRuleDisabled(76)) { |
2403 | if (1 |
2404 | && [&]() { |
2405 | return Helper.matchCombineDivRem(*MIs[0], MatchData76); |
2406 | return true; |
2407 | }()) { |
2408 | Helper.applyCombineDivRem(*MIs[0], MatchData76); |
2409 | return true; |
2410 | } |
2411 | } |
2412 | // Leaf name: fold_binop_into_select |
2413 | // Rule: fold_binop_into_select |
2414 | if (!RuleConfig->isRuleDisabled(98)) { |
2415 | if (1 |
2416 | && [&]() { |
2417 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
2418 | return true; |
2419 | }()) { |
2420 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
2421 | return true; |
2422 | } |
2423 | } |
2424 | return false; |
2425 | } |
2426 | if (Partition == 31 /* TargetOpcode::G_UREM */) { |
2427 | // Leaf name: binop_left_to_zero |
2428 | // Rule: binop_left_to_zero |
2429 | if (!RuleConfig->isRuleDisabled(24)) { |
2430 | if (1 |
2431 | && [&]() { |
2432 | return Helper.matchOperandIsZero(*MIs[0], 1); |
2433 | return true; |
2434 | }()) { |
2435 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
2436 | return true; |
2437 | } |
2438 | } |
2439 | // Leaf name: urem_pow2_to_mask |
2440 | // Rule: urem_pow2_to_mask |
2441 | if (!RuleConfig->isRuleDisabled(47)) { |
2442 | if (1 |
2443 | && [&]() { |
2444 | return Helper.matchOperandIsKnownToBeAPowerOfTwo(*MIs[0], 2); |
2445 | return true; |
2446 | }()) { |
2447 | Helper.applySimplifyURemByPow2(*MIs[0]); |
2448 | return true; |
2449 | } |
2450 | } |
2451 | // Leaf name: div_rem_to_divrem |
2452 | // Rule: div_rem_to_divrem |
2453 | if (!RuleConfig->isRuleDisabled(76)) { |
2454 | if (1 |
2455 | && [&]() { |
2456 | return Helper.matchCombineDivRem(*MIs[0], MatchData76); |
2457 | return true; |
2458 | }()) { |
2459 | Helper.applyCombineDivRem(*MIs[0], MatchData76); |
2460 | return true; |
2461 | } |
2462 | } |
2463 | // Leaf name: fold_binop_into_select |
2464 | // Rule: fold_binop_into_select |
2465 | if (!RuleConfig->isRuleDisabled(98)) { |
2466 | if (1 |
2467 | && [&]() { |
2468 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
2469 | return true; |
2470 | }()) { |
2471 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
2472 | return true; |
2473 | } |
2474 | } |
2475 | return false; |
2476 | } |
2477 | if (Partition == 32 /* TargetOpcode::G_INTTOPTR */) { |
2478 | // Leaf name: p2i_to_i2p |
2479 | // Rule: p2i_to_i2p |
2480 | if (!RuleConfig->isRuleDisabled(26)) { |
2481 | if (1 |
2482 | && [&]() { |
2483 | return Helper.matchCombineI2PToP2I(*MIs[0], MatchData26); |
2484 | return true; |
2485 | }()) { |
2486 | Helper.applyCombineI2PToP2I(*MIs[0], MatchData26); |
2487 | return true; |
2488 | } |
2489 | } |
2490 | return false; |
2491 | } |
2492 | if (Partition == 33 /* TargetOpcode::G_PTRTOINT */) { |
2493 | Partition = -1; |
2494 | if (MIs.size() <= 1) MIs.resize(2); |
2495 | MIs[1] = nullptr; |
2496 | if (MIs[0]->getOperand(1).isReg()) |
2497 | MIs[1] = MRI.getVRegDef(MIs[0]->getOperand(1).getReg()); |
2498 | if (MIs[1] != nullptr) Partition = 0; |
2499 | if (Partition == -1) return false; |
2500 | if (Partition == 0 /* true */) { |
2501 | Partition = -1; |
2502 | switch (MIs[1]->getOpcode()) { |
2503 | case TargetOpcode::G_INTTOPTR: Partition = 0; break; |
2504 | } |
2505 | // Default case but without conflicting with potential default case in selection. |
2506 | if (Partition == -1) return false; |
2507 | if (Partition == 0 /* TargetOpcode::G_INTTOPTR */) { |
2508 | // Leaf name: i2p_to_p2i |
2509 | // Rule: i2p_to_p2i |
2510 | if (!RuleConfig->isRuleDisabled(27)) { |
2511 | if (1 |
2512 | && [&]() { |
2513 | MatchData27 = MIs[1]->getOperand(1).getReg(); |
2514 | return true; |
2515 | }()) { |
2516 | Helper.applyCombineP2IToI2P(*MIs[0], MatchData27); |
2517 | return true; |
2518 | } |
2519 | } |
2520 | return false; |
2521 | } |
2522 | } |
2523 | } |
2524 | if (Partition == 34 /* TargetOpcode::G_ANYEXT */) { |
2525 | // Leaf name: anyext_trunc_fold |
2526 | // Rule: anyext_trunc_fold |
2527 | if (!RuleConfig->isRuleDisabled(28)) { |
2528 | if (1 |
2529 | && [&]() { |
2530 | return Helper.matchCombineAnyExtTrunc(*MIs[0], MatchData28); |
2531 | return true; |
2532 | }()) { |
2533 | return Helper.replaceSingleDefInstWithReg(*MIs[0], MatchData28); |
2534 | return true; |
2535 | } |
2536 | } |
2537 | // Leaf name: ext_ext_fold |
2538 | // Rule: ext_ext_fold |
2539 | if (!RuleConfig->isRuleDisabled(51)) { |
2540 | if (1 |
2541 | && [&]() { |
2542 | return Helper.matchCombineExtOfExt(*MIs[0], MatchData51); |
2543 | return true; |
2544 | }()) { |
2545 | Helper.applyCombineExtOfExt(*MIs[0], MatchData51); |
2546 | return true; |
2547 | } |
2548 | } |
2549 | return false; |
2550 | } |
2551 | if (Partition == 35 /* TargetOpcode::G_FNEG */) { |
2552 | Partition = -1; |
2553 | if (MIs.size() <= 1) MIs.resize(2); |
2554 | MIs[1] = nullptr; |
2555 | if (MIs[0]->getOperand(1).isReg()) |
2556 | MIs[1] = MRI.getVRegDef(MIs[0]->getOperand(1).getReg()); |
2557 | if (MIs[1] == nullptr) Partition = 1; |
2558 | if (MIs[1] != nullptr) Partition = 0; |
2559 | if (Partition == -1) return false; |
2560 | if (Partition == 0 /* true */) { |
2561 | Partition = -1; |
Value stored to 'Partition' is never read | |
2562 | switch (MIs[1]->getOpcode()) { |
2563 | case TargetOpcode::G_FNEG: Partition = 0; break; |
2564 | default: Partition = 1; break; |
2565 | } |
2566 | // Default case but without conflicting with potential default case in selection. |
2567 | if (Partition == -1) return false; |
2568 | if (Partition == 0 /* TargetOpcode::G_FNEG */) { |
2569 | // Leaf name: fneg_fneg_fold |
2570 | // Rule: fneg_fneg_fold |
2571 | if (!RuleConfig->isRuleDisabled(29)) { |
2572 | if (1 |
2573 | && [&]() { |
2574 | MatchData29 = MIs[1]->getOperand(1).getReg(); |
2575 | return true; |
2576 | }()) { |
2577 | return Helper.replaceSingleDefInstWithReg(*MIs[0], MatchData29); |
2578 | return true; |
2579 | } |
2580 | } |
2581 | // Leaf name: constant_fp_op |
2582 | // Rule: constant_fp_op |
2583 | if (!RuleConfig->isRuleDisabled(62)) { |
2584 | if (1 |
2585 | && [&]() { |
2586 | return Helper.matchCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2587 | return true; |
2588 | }()) { |
2589 | Helper.applyCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2590 | return true; |
2591 | } |
2592 | } |
2593 | return false; |
2594 | } |
2595 | if (Partition == 1 /* * or nullptr */) { |
2596 | // Leaf name: constant_fp_op |
2597 | // Rule: constant_fp_op |
2598 | if (!RuleConfig->isRuleDisabled(62)) { |
2599 | if (1 |
2600 | && [&]() { |
2601 | return Helper.matchCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2602 | return true; |
2603 | }()) { |
2604 | Helper.applyCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2605 | return true; |
2606 | } |
2607 | } |
2608 | return false; |
2609 | } |
2610 | } |
2611 | if (Partition == 1 /* false */) { |
2612 | // Leaf name: constant_fp_op |
2613 | // Rule: constant_fp_op |
2614 | if (!RuleConfig->isRuleDisabled(62)) { |
2615 | if (1 |
2616 | && [&]() { |
2617 | return Helper.matchCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2618 | return true; |
2619 | }()) { |
2620 | Helper.applyCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2621 | return true; |
2622 | } |
2623 | } |
2624 | return false; |
2625 | } |
2626 | } |
2627 | if (Partition == 36 /* TargetOpcode::G_PHI */) { |
2628 | // Leaf name: extend_through_phis |
2629 | // Rule: extend_through_phis |
2630 | if (!RuleConfig->isRuleDisabled(32)) { |
2631 | if (1 |
2632 | && [&]() { |
2633 | return Helper.matchExtendThroughPhis(*MIs[0], MatchData32); |
2634 | return true; |
2635 | }()) { |
2636 | Helper.applyExtendThroughPhis(*MIs[0], MatchData32); |
2637 | return true; |
2638 | } |
2639 | } |
2640 | return false; |
2641 | } |
2642 | if (Partition == 37 /* TargetOpcode::G_SEXT_INREG */) { |
2643 | // Leaf name: sext_inreg_of_load |
2644 | // Rule: sext_inreg_of_load |
2645 | if (!RuleConfig->isRuleDisabled(38)) { |
2646 | if (1 |
2647 | && [&]() { |
2648 | return Helper.matchSextInRegOfLoad(*MIs[0], MatchData38); |
2649 | return true; |
2650 | }()) { |
2651 | Helper.applySextInRegOfLoad(*MIs[0], MatchData38); |
2652 | return true; |
2653 | } |
2654 | } |
2655 | // Leaf name: redundant_sext_inreg |
2656 | // Rule: redundant_sext_inreg |
2657 | if (!RuleConfig->isRuleDisabled(45)) { |
2658 | if (1 |
2659 | && [&]() { |
2660 | return Helper.matchRedundantSExtInReg(*MIs[0]); |
2661 | return true; |
2662 | }()) { |
2663 | return Helper.replaceSingleDefInstWithOperand(*MIs[0], 1); |
2664 | return true; |
2665 | } |
2666 | } |
2667 | // Leaf name: bitfield_extract_from_sext_inreg |
2668 | // Rule: bitfield_extract_from_sext_inreg |
2669 | if (!RuleConfig->isRuleDisabled(79)) { |
2670 | if (1 |
2671 | && [&]() { |
2672 | return Helper.matchBitfieldExtractFromSExtInReg(*MIs[0], MatchData79); |
2673 | return true; |
2674 | }()) { |
2675 | Helper.applyBuildFn(*MIs[0], MatchData79); |
2676 | return true; |
2677 | } |
2678 | } |
2679 | return false; |
2680 | } |
2681 | if (Partition == 38 /* TargetOpcode::G_ZEXT */) { |
2682 | // Leaf name: zext_trunc_fold |
2683 | // Rule: zext_trunc_fold |
2684 | if (!RuleConfig->isRuleDisabled(48)) { |
2685 | if (1 |
2686 | && [&]() { |
2687 | return Helper.matchCombineZextTrunc(*MIs[0], MatchData48); |
2688 | return true; |
2689 | }()) { |
2690 | return Helper.replaceSingleDefInstWithReg(*MIs[0], MatchData48); |
2691 | return true; |
2692 | } |
2693 | } |
2694 | // Leaf name: ext_ext_fold |
2695 | // Rule: ext_ext_fold |
2696 | if (!RuleConfig->isRuleDisabled(51)) { |
2697 | if (1 |
2698 | && [&]() { |
2699 | return Helper.matchCombineExtOfExt(*MIs[0], MatchData51); |
2700 | return true; |
2701 | }()) { |
2702 | Helper.applyCombineExtOfExt(*MIs[0], MatchData51); |
2703 | return true; |
2704 | } |
2705 | } |
2706 | return false; |
2707 | } |
2708 | if (Partition == 39 /* TargetOpcode::G_ICMP */) { |
2709 | // Leaf name: icmp_to_true_false_known_bits |
2710 | // Rule: icmp_to_true_false_known_bits |
2711 | if (!RuleConfig->isRuleDisabled(49)) { |
2712 | if (1 |
2713 | && [&]() { |
2714 | return Helper.matchICmpToTrueFalseKnownBits(*MIs[0], MatchData49); |
2715 | return true; |
2716 | }()) { |
2717 | Helper.replaceInstWithConstant(*MIs[0], MatchData49); |
2718 | return true; |
2719 | } |
2720 | } |
2721 | // Leaf name: icmp_to_lhs_known_bits |
2722 | // Rule: icmp_to_lhs_known_bits |
2723 | if (!RuleConfig->isRuleDisabled(50)) { |
2724 | if (1 |
2725 | && [&]() { |
2726 | return Helper.matchICmpToLHSKnownBits(*MIs[0], MatchData50); |
2727 | return true; |
2728 | }()) { |
2729 | Helper.applyBuildFn(*MIs[0], MatchData50); |
2730 | return true; |
2731 | } |
2732 | } |
2733 | // Leaf name: icmp_redundant_trunc |
2734 | // Rule: icmp_redundant_trunc |
2735 | if (!RuleConfig->isRuleDisabled(100)) { |
2736 | if (1 |
2737 | && [&]() { |
2738 | return matchICmpRedundantTrunc(*MIs[0], MRI, Helper.getKnownBits(), MatchData100); |
2739 | return true; |
2740 | }()) { |
2741 | applyICmpRedundantTrunc(*MIs[0], MRI, B, Observer, MatchData100); |
2742 | return true; |
2743 | } |
2744 | } |
2745 | return false; |
2746 | } |
2747 | if (Partition == 40 /* TargetOpcode::G_SEXT */) { |
2748 | // Leaf name: ext_ext_fold |
2749 | // Rule: ext_ext_fold |
2750 | if (!RuleConfig->isRuleDisabled(51)) { |
2751 | if (1 |
2752 | && [&]() { |
2753 | return Helper.matchCombineExtOfExt(*MIs[0], MatchData51); |
2754 | return true; |
2755 | }()) { |
2756 | Helper.applyCombineExtOfExt(*MIs[0], MatchData51); |
2757 | return true; |
2758 | } |
2759 | } |
2760 | return false; |
2761 | } |
2762 | if (Partition == 41 /* TargetOpcode::G_BR */) { |
2763 | // Leaf name: opt_brcond_by_inverting_cond |
2764 | // Rule: opt_brcond_by_inverting_cond |
2765 | if (!RuleConfig->isRuleDisabled(53)) { |
2766 | if (1 |
2767 | && [&]() { |
2768 | return Helper.matchOptBrCondByInvertingCond(*MIs[0], MatchData53); |
2769 | return true; |
2770 | }()) { |
2771 | Helper.applyOptBrCondByInvertingCond(*MIs[0], MatchData53); |
2772 | return true; |
2773 | } |
2774 | } |
2775 | return false; |
2776 | } |
2777 | if (Partition == 42 /* TargetOpcode::G_FABS */) { |
2778 | Partition = -1; |
2779 | if (MIs.size() <= 1) MIs.resize(2); |
2780 | MIs[1] = nullptr; |
2781 | if (MIs[0]->getOperand(1).isReg()) |
2782 | MIs[1] = MRI.getVRegDef(MIs[0]->getOperand(1).getReg()); |
2783 | if (MIs[1] == nullptr) Partition = 1; |
2784 | if (MIs[1] != nullptr) Partition = 0; |
2785 | if (Partition == -1) return false; |
2786 | if (Partition == 0 /* true */) { |
2787 | Partition = -1; |
2788 | switch (MIs[1]->getOpcode()) { |
2789 | case TargetOpcode::G_FABS: Partition = 0; break; |
2790 | default: Partition = 1; break; |
2791 | } |
2792 | // Default case but without conflicting with potential default case in selection. |
2793 | if (Partition == -1) return false; |
2794 | if (Partition == 0 /* TargetOpcode::G_FABS */) { |
2795 | // Leaf name: fabs_fabs_fold |
2796 | // Rule: fabs_fabs_fold |
2797 | if (!RuleConfig->isRuleDisabled(55)) { |
2798 | if (1 |
2799 | && [&]() { |
2800 | MatchData55 = MIs[0]->getOperand(1).getReg(); |
2801 | return true; |
2802 | }()) { |
2803 | return Helper.replaceSingleDefInstWithReg(*MIs[0], MatchData55); |
2804 | return true; |
2805 | } |
2806 | } |
2807 | // Leaf name: constant_fp_op |
2808 | // Rule: constant_fp_op |
2809 | if (!RuleConfig->isRuleDisabled(62)) { |
2810 | if (1 |
2811 | && [&]() { |
2812 | return Helper.matchCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2813 | return true; |
2814 | }()) { |
2815 | Helper.applyCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2816 | return true; |
2817 | } |
2818 | } |
2819 | // Leaf name: fabs_fneg_fold |
2820 | // Rule: fabs_fneg_fold |
2821 | if (!RuleConfig->isRuleDisabled(84)) { |
2822 | if (1 |
2823 | && [&]() { |
2824 | return Helper.matchCombineFAbsOfFNeg(*MIs[0], MatchData84); |
2825 | return true; |
2826 | }()) { |
2827 | Helper.applyBuildFnNoErase(*MIs[0], MatchData84); |
2828 | return true; |
2829 | } |
2830 | } |
2831 | return false; |
2832 | } |
2833 | if (Partition == 1 /* * or nullptr */) { |
2834 | // Leaf name: constant_fp_op |
2835 | // Rule: constant_fp_op |
2836 | if (!RuleConfig->isRuleDisabled(62)) { |
2837 | if (1 |
2838 | && [&]() { |
2839 | return Helper.matchCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2840 | return true; |
2841 | }()) { |
2842 | Helper.applyCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2843 | return true; |
2844 | } |
2845 | } |
2846 | // Leaf name: fabs_fneg_fold |
2847 | // Rule: fabs_fneg_fold |
2848 | if (!RuleConfig->isRuleDisabled(84)) { |
2849 | if (1 |
2850 | && [&]() { |
2851 | return Helper.matchCombineFAbsOfFNeg(*MIs[0], MatchData84); |
2852 | return true; |
2853 | }()) { |
2854 | Helper.applyBuildFnNoErase(*MIs[0], MatchData84); |
2855 | return true; |
2856 | } |
2857 | } |
2858 | return false; |
2859 | } |
2860 | } |
2861 | if (Partition == 1 /* false */) { |
2862 | // Leaf name: constant_fp_op |
2863 | // Rule: constant_fp_op |
2864 | if (!RuleConfig->isRuleDisabled(62)) { |
2865 | if (1 |
2866 | && [&]() { |
2867 | return Helper.matchCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2868 | return true; |
2869 | }()) { |
2870 | Helper.applyCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2871 | return true; |
2872 | } |
2873 | } |
2874 | // Leaf name: fabs_fneg_fold |
2875 | // Rule: fabs_fneg_fold |
2876 | if (!RuleConfig->isRuleDisabled(84)) { |
2877 | if (1 |
2878 | && [&]() { |
2879 | return Helper.matchCombineFAbsOfFNeg(*MIs[0], MatchData84); |
2880 | return true; |
2881 | }()) { |
2882 | Helper.applyBuildFnNoErase(*MIs[0], MatchData84); |
2883 | return true; |
2884 | } |
2885 | } |
2886 | return false; |
2887 | } |
2888 | } |
2889 | if (Partition == 43 /* TargetOpcode::G_MERGE_VALUES */) { |
2890 | // Leaf name: merge_unmerge |
2891 | // Rule: merge_unmerge |
2892 | if (!RuleConfig->isRuleDisabled(59)) { |
2893 | if (1 |
2894 | && [&]() { |
2895 | return Helper.matchCombineMergeUnmerge(*MIs[0], MatchData59); |
2896 | return true; |
2897 | }()) { |
2898 | Helper.replaceSingleDefInstWithReg(*MIs[0], MatchData59); |
2899 | return true; |
2900 | } |
2901 | } |
2902 | return false; |
2903 | } |
2904 | if (Partition == 44 /* TargetOpcode::G_FPTRUNC */) { |
2905 | // Leaf name: constant_fp_op |
2906 | // Rule: constant_fp_op |
2907 | if (!RuleConfig->isRuleDisabled(62)) { |
2908 | if (1 |
2909 | && [&]() { |
2910 | return Helper.matchCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2911 | return true; |
2912 | }()) { |
2913 | Helper.applyCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2914 | return true; |
2915 | } |
2916 | } |
2917 | return false; |
2918 | } |
2919 | if (Partition == 45 /* TargetOpcode::G_FSQRT */) { |
2920 | // Leaf name: constant_fp_op |
2921 | // Rule: constant_fp_op |
2922 | if (!RuleConfig->isRuleDisabled(62)) { |
2923 | if (1 |
2924 | && [&]() { |
2925 | return Helper.matchCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2926 | return true; |
2927 | }()) { |
2928 | Helper.applyCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2929 | return true; |
2930 | } |
2931 | } |
2932 | return false; |
2933 | } |
2934 | if (Partition == 46 /* TargetOpcode::G_FLOG2 */) { |
2935 | // Leaf name: constant_fp_op |
2936 | // Rule: constant_fp_op |
2937 | if (!RuleConfig->isRuleDisabled(62)) { |
2938 | if (1 |
2939 | && [&]() { |
2940 | return Helper.matchCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2941 | return true; |
2942 | }()) { |
2943 | Helper.applyCombineConstantFoldFpUnary(*MIs[0], MatchData62); |
2944 | return true; |
2945 | } |
2946 | } |
2947 | return false; |
2948 | } |
2949 | if (Partition == 47 /* TargetOpcode::G_UMULO */) { |
2950 | // Leaf name: mulo_by_2 |
2951 | // Rule: mulo_by_2 |
2952 | if (!RuleConfig->isRuleDisabled(65)) { |
2953 | if (1 |
2954 | && [&]() { |
2955 | return Helper.matchMulOBy2(*MIs[0], MatchData65); |
2956 | return true; |
2957 | }()) { |
2958 | Helper.applyBuildFnNoErase(*MIs[0], MatchData65); |
2959 | return true; |
2960 | } |
2961 | } |
2962 | // Leaf name: mulo_by_0 |
2963 | // Rule: mulo_by_0 |
2964 | if (!RuleConfig->isRuleDisabled(66)) { |
2965 | if (1 |
2966 | && [&]() { |
2967 | return Helper.matchMulOBy0(*MIs[0], MatchData66); |
2968 | return true; |
2969 | }()) { |
2970 | Helper.applyBuildFn(*MIs[0], MatchData66); |
2971 | return true; |
2972 | } |
2973 | } |
2974 | return false; |
2975 | } |
2976 | if (Partition == 48 /* TargetOpcode::G_SMULO */) { |
2977 | // Leaf name: mulo_by_2 |
2978 | // Rule: mulo_by_2 |
2979 | if (!RuleConfig->isRuleDisabled(65)) { |
2980 | if (1 |
2981 | && [&]() { |
2982 | return Helper.matchMulOBy2(*MIs[0], MatchData65); |
2983 | return true; |
2984 | }()) { |
2985 | Helper.applyBuildFnNoErase(*MIs[0], MatchData65); |
2986 | return true; |
2987 | } |
2988 | } |
2989 | // Leaf name: mulo_by_0 |
2990 | // Rule: mulo_by_0 |
2991 | if (!RuleConfig->isRuleDisabled(66)) { |
2992 | if (1 |
2993 | && [&]() { |
2994 | return Helper.matchMulOBy0(*MIs[0], MatchData66); |
2995 | return true; |
2996 | }()) { |
2997 | Helper.applyBuildFn(*MIs[0], MatchData66); |
2998 | return true; |
2999 | } |
3000 | } |
3001 | return false; |
3002 | } |
3003 | if (Partition == 49 /* TargetOpcode::G_UADDO */) { |
3004 | // Leaf name: addo_by_0 |
3005 | // Rule: addo_by_0 |
3006 | if (!RuleConfig->isRuleDisabled(67)) { |
3007 | if (1 |
3008 | && [&]() { |
3009 | return Helper.matchAddOBy0(*MIs[0], MatchData67); |
3010 | return true; |
3011 | }()) { |
3012 | Helper.applyBuildFn(*MIs[0], MatchData67); |
3013 | return true; |
3014 | } |
3015 | } |
3016 | return false; |
3017 | } |
3018 | if (Partition == 50 /* TargetOpcode::G_SADDO */) { |
3019 | // Leaf name: addo_by_0 |
3020 | // Rule: addo_by_0 |
3021 | if (!RuleConfig->isRuleDisabled(67)) { |
3022 | if (1 |
3023 | && [&]() { |
3024 | return Helper.matchAddOBy0(*MIs[0], MatchData67); |
3025 | return true; |
3026 | }()) { |
3027 | Helper.applyBuildFn(*MIs[0], MatchData67); |
3028 | return true; |
3029 | } |
3030 | } |
3031 | return false; |
3032 | } |
3033 | if (Partition == 51 /* TargetOpcode::G_UADDE */) { |
3034 | // Leaf name: adde_to_addo |
3035 | // Rule: adde_to_addo |
3036 | if (!RuleConfig->isRuleDisabled(68)) { |
3037 | if (1 |
3038 | && [&]() { |
3039 | return Helper.matchAddEToAddO(*MIs[0], MatchData68); |
3040 | return true; |
3041 | }()) { |
3042 | Helper.applyBuildFnNoErase(*MIs[0], MatchData68); |
3043 | return true; |
3044 | } |
3045 | } |
3046 | return false; |
3047 | } |
3048 | if (Partition == 52 /* TargetOpcode::G_SADDE */) { |
3049 | // Leaf name: adde_to_addo |
3050 | // Rule: adde_to_addo |
3051 | if (!RuleConfig->isRuleDisabled(68)) { |
3052 | if (1 |
3053 | && [&]() { |
3054 | return Helper.matchAddEToAddO(*MIs[0], MatchData68); |
3055 | return true; |
3056 | }()) { |
3057 | Helper.applyBuildFnNoErase(*MIs[0], MatchData68); |
3058 | return true; |
3059 | } |
3060 | } |
3061 | return false; |
3062 | } |
3063 | if (Partition == 53 /* TargetOpcode::G_USUBE */) { |
3064 | // Leaf name: adde_to_addo |
3065 | // Rule: adde_to_addo |
3066 | if (!RuleConfig->isRuleDisabled(68)) { |
3067 | if (1 |
3068 | && [&]() { |
3069 | return Helper.matchAddEToAddO(*MIs[0], MatchData68); |
3070 | return true; |
3071 | }()) { |
3072 | Helper.applyBuildFnNoErase(*MIs[0], MatchData68); |
3073 | return true; |
3074 | } |
3075 | } |
3076 | return false; |
3077 | } |
3078 | if (Partition == 54 /* TargetOpcode::G_SSUBE */) { |
3079 | // Leaf name: adde_to_addo |
3080 | // Rule: adde_to_addo |
3081 | if (!RuleConfig->isRuleDisabled(68)) { |
3082 | if (1 |
3083 | && [&]() { |
3084 | return Helper.matchAddEToAddO(*MIs[0], MatchData68); |
3085 | return true; |
3086 | }()) { |
3087 | Helper.applyBuildFnNoErase(*MIs[0], MatchData68); |
3088 | return true; |
3089 | } |
3090 | } |
3091 | return false; |
3092 | } |
3093 | if (Partition == 55 /* TargetOpcode::G_FMINNUM */) { |
3094 | // Leaf name: combine_minmax_nan |
3095 | // Rule: combine_minmax_nan |
3096 | if (!RuleConfig->isRuleDisabled(69)) { |
3097 | if (1 |
3098 | && [&]() { |
3099 | return Helper.matchCombineFMinMaxNaN(*MIs[0], MatchData69); |
3100 | return true; |
3101 | }()) { |
3102 | Helper.replaceSingleDefInstWithOperand(*MIs[0], MatchData69); |
3103 | return true; |
3104 | } |
3105 | } |
3106 | // Leaf name: fold_binop_into_select |
3107 | // Rule: fold_binop_into_select |
3108 | if (!RuleConfig->isRuleDisabled(98)) { |
3109 | if (1 |
3110 | && [&]() { |
3111 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3112 | return true; |
3113 | }()) { |
3114 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3115 | return true; |
3116 | } |
3117 | } |
3118 | return false; |
3119 | } |
3120 | if (Partition == 56 /* TargetOpcode::G_FMAXNUM */) { |
3121 | // Leaf name: combine_minmax_nan |
3122 | // Rule: combine_minmax_nan |
3123 | if (!RuleConfig->isRuleDisabled(69)) { |
3124 | if (1 |
3125 | && [&]() { |
3126 | return Helper.matchCombineFMinMaxNaN(*MIs[0], MatchData69); |
3127 | return true; |
3128 | }()) { |
3129 | Helper.replaceSingleDefInstWithOperand(*MIs[0], MatchData69); |
3130 | return true; |
3131 | } |
3132 | } |
3133 | // Leaf name: fold_binop_into_select |
3134 | // Rule: fold_binop_into_select |
3135 | if (!RuleConfig->isRuleDisabled(98)) { |
3136 | if (1 |
3137 | && [&]() { |
3138 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3139 | return true; |
3140 | }()) { |
3141 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3142 | return true; |
3143 | } |
3144 | } |
3145 | return false; |
3146 | } |
3147 | if (Partition == 57 /* TargetOpcode::G_FMINIMUM */) { |
3148 | // Leaf name: combine_minmax_nan |
3149 | // Rule: combine_minmax_nan |
3150 | if (!RuleConfig->isRuleDisabled(69)) { |
3151 | if (1 |
3152 | && [&]() { |
3153 | return Helper.matchCombineFMinMaxNaN(*MIs[0], MatchData69); |
3154 | return true; |
3155 | }()) { |
3156 | Helper.replaceSingleDefInstWithOperand(*MIs[0], MatchData69); |
3157 | return true; |
3158 | } |
3159 | } |
3160 | // Leaf name: fold_binop_into_select |
3161 | // Rule: fold_binop_into_select |
3162 | if (!RuleConfig->isRuleDisabled(98)) { |
3163 | if (1 |
3164 | && [&]() { |
3165 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3166 | return true; |
3167 | }()) { |
3168 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3169 | return true; |
3170 | } |
3171 | } |
3172 | return false; |
3173 | } |
3174 | if (Partition == 58 /* TargetOpcode::G_FMAXIMUM */) { |
3175 | // Leaf name: combine_minmax_nan |
3176 | // Rule: combine_minmax_nan |
3177 | if (!RuleConfig->isRuleDisabled(69)) { |
3178 | if (1 |
3179 | && [&]() { |
3180 | return Helper.matchCombineFMinMaxNaN(*MIs[0], MatchData69); |
3181 | return true; |
3182 | }()) { |
3183 | Helper.replaceSingleDefInstWithOperand(*MIs[0], MatchData69); |
3184 | return true; |
3185 | } |
3186 | } |
3187 | // Leaf name: fold_binop_into_select |
3188 | // Rule: fold_binop_into_select |
3189 | if (!RuleConfig->isRuleDisabled(98)) { |
3190 | if (1 |
3191 | && [&]() { |
3192 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3193 | return true; |
3194 | }()) { |
3195 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3196 | return true; |
3197 | } |
3198 | } |
3199 | return false; |
3200 | } |
3201 | if (Partition == 59 /* TargetOpcode::G_SSHLSAT */) { |
3202 | // Leaf name: shift_immed_chain |
3203 | // Rule: shift_immed_chain |
3204 | if (!RuleConfig->isRuleDisabled(72)) { |
3205 | if (1 |
3206 | && [&]() { |
3207 | return Helper.matchShiftImmedChain(*MIs[0], MatchData72); |
3208 | return true; |
3209 | }()) { |
3210 | Helper.applyShiftImmedChain(*MIs[0], MatchData72); |
3211 | return true; |
3212 | } |
3213 | } |
3214 | // Leaf name: shift_of_shifted_logic_chain |
3215 | // Rule: shift_of_shifted_logic_chain |
3216 | if (!RuleConfig->isRuleDisabled(73)) { |
3217 | if (1 |
3218 | && [&]() { |
3219 | return Helper.matchShiftOfShiftedLogic(*MIs[0], MatchData73); |
3220 | return true; |
3221 | }()) { |
3222 | Helper.applyShiftOfShiftedLogic(*MIs[0], MatchData73); |
3223 | return true; |
3224 | } |
3225 | } |
3226 | return false; |
3227 | } |
3228 | if (Partition == 60 /* TargetOpcode::G_USHLSAT */) { |
3229 | // Leaf name: shift_immed_chain |
3230 | // Rule: shift_immed_chain |
3231 | if (!RuleConfig->isRuleDisabled(72)) { |
3232 | if (1 |
3233 | && [&]() { |
3234 | return Helper.matchShiftImmedChain(*MIs[0], MatchData72); |
3235 | return true; |
3236 | }()) { |
3237 | Helper.applyShiftImmedChain(*MIs[0], MatchData72); |
3238 | return true; |
3239 | } |
3240 | } |
3241 | // Leaf name: shift_of_shifted_logic_chain |
3242 | // Rule: shift_of_shifted_logic_chain |
3243 | if (!RuleConfig->isRuleDisabled(73)) { |
3244 | if (1 |
3245 | && [&]() { |
3246 | return Helper.matchShiftOfShiftedLogic(*MIs[0], MatchData73); |
3247 | return true; |
3248 | }()) { |
3249 | Helper.applyShiftOfShiftedLogic(*MIs[0], MatchData73); |
3250 | return true; |
3251 | } |
3252 | } |
3253 | return false; |
3254 | } |
3255 | if (Partition == 61 /* TargetOpcode::G_FSHL */) { |
3256 | // Leaf name: funnel_shift_to_rotate |
3257 | // Rule: funnel_shift_to_rotate |
3258 | if (!RuleConfig->isRuleDisabled(78)) { |
3259 | if (1 |
3260 | && [&]() { |
3261 | return Helper.matchFunnelShiftToRotate(*MIs[0]); |
3262 | return true; |
3263 | }()) { |
3264 | Helper.applyFunnelShiftToRotate(*MIs[0]); |
3265 | return true; |
3266 | } |
3267 | } |
3268 | return false; |
3269 | } |
3270 | if (Partition == 62 /* TargetOpcode::G_FSHR */) { |
3271 | // Leaf name: funnel_shift_to_rotate |
3272 | // Rule: funnel_shift_to_rotate |
3273 | if (!RuleConfig->isRuleDisabled(78)) { |
3274 | if (1 |
3275 | && [&]() { |
3276 | return Helper.matchFunnelShiftToRotate(*MIs[0]); |
3277 | return true; |
3278 | }()) { |
3279 | Helper.applyFunnelShiftToRotate(*MIs[0]); |
3280 | return true; |
3281 | } |
3282 | } |
3283 | return false; |
3284 | } |
3285 | if (Partition == 63 /* TargetOpcode::G_UMULH */) { |
3286 | // Leaf name: mulh_to_lshr |
3287 | // Rule: mulh_to_lshr |
3288 | if (!RuleConfig->isRuleDisabled(87)) { |
3289 | if (1 |
3290 | && [&]() { |
3291 | return Helper.matchUMulHToLShr(*MIs[0]); |
3292 | return true; |
3293 | }()) { |
3294 | Helper.applyUMulHToLShr(*MIs[0]); |
3295 | return true; |
3296 | } |
3297 | } |
3298 | return false; |
3299 | } |
3300 | if (Partition == 64 /* TargetOpcode::G_FADD */) { |
3301 | // Leaf name: redundant_neg_operands |
3302 | // Rule: redundant_neg_operands |
3303 | if (!RuleConfig->isRuleDisabled(88)) { |
3304 | if (1 |
3305 | && [&]() { |
3306 | return Helper.matchRedundantNegOperands(*MIs[0], MatchData88); |
3307 | return true; |
3308 | }()) { |
3309 | Helper.applyBuildFnNoErase(*MIs[0], MatchData88); |
3310 | return true; |
3311 | } |
3312 | } |
3313 | // Leaf name: combine_fadd_fmul_to_fmad_or_fma |
3314 | // Rule: combine_fadd_fmul_to_fmad_or_fma |
3315 | if (!RuleConfig->isRuleDisabled(90)) { |
3316 | if (1 |
3317 | && [&]() { |
3318 | return Helper.matchCombineFAddFMulToFMadOrFMA(*MIs[0], |
3319 | MatchData90); |
3320 | return true; |
3321 | }()) { |
3322 | Helper.applyBuildFn(*MIs[0], MatchData90); |
3323 | return true; |
3324 | } |
3325 | } |
3326 | // Leaf name: combine_fadd_fpext_fmul_to_fmad_or_fma |
3327 | // Rule: combine_fadd_fpext_fmul_to_fmad_or_fma |
3328 | if (!RuleConfig->isRuleDisabled(91)) { |
3329 | if (1 |
3330 | && [&]() { |
3331 | return Helper.matchCombineFAddFpExtFMulToFMadOrFMA(*MIs[0], |
3332 | MatchData91); |
3333 | return true; |
3334 | }()) { |
3335 | Helper.applyBuildFn(*MIs[0], MatchData91); |
3336 | return true; |
3337 | } |
3338 | } |
3339 | // Leaf name: combine_fadd_fma_fmul_to_fmad_or_fma |
3340 | // Rule: combine_fadd_fma_fmul_to_fmad_or_fma |
3341 | if (!RuleConfig->isRuleDisabled(92)) { |
3342 | if (1 |
3343 | && [&]() { |
3344 | return Helper.matchCombineFAddFMAFMulToFMadOrFMA(*MIs[0], |
3345 | MatchData92); |
3346 | return true; |
3347 | }()) { |
3348 | Helper.applyBuildFn(*MIs[0], MatchData92); |
3349 | return true; |
3350 | } |
3351 | } |
3352 | // Leaf name: combine_fadd_fpext_fma_fmul_to_fmad_or_fma |
3353 | // Rule: combine_fadd_fpext_fma_fmul_to_fmad_or_fma |
3354 | if (!RuleConfig->isRuleDisabled(93)) { |
3355 | if (1 |
3356 | && [&]() { |
3357 | return Helper.matchCombineFAddFpExtFMulToFMadOrFMAAggressive( |
3358 | *MIs[0], MatchData93); |
3359 | return true; |
3360 | }()) { |
3361 | Helper.applyBuildFn(*MIs[0], MatchData93); |
3362 | return true; |
3363 | } |
3364 | } |
3365 | // Leaf name: fold_binop_into_select |
3366 | // Rule: fold_binop_into_select |
3367 | if (!RuleConfig->isRuleDisabled(98)) { |
3368 | if (1 |
3369 | && [&]() { |
3370 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3371 | return true; |
3372 | }()) { |
3373 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3374 | return true; |
3375 | } |
3376 | } |
3377 | return false; |
3378 | } |
3379 | if (Partition == 65 /* TargetOpcode::G_FSUB */) { |
3380 | // Leaf name: redundant_neg_operands |
3381 | // Rule: redundant_neg_operands |
3382 | if (!RuleConfig->isRuleDisabled(88)) { |
3383 | if (1 |
3384 | && [&]() { |
3385 | return Helper.matchRedundantNegOperands(*MIs[0], MatchData88); |
3386 | return true; |
3387 | }()) { |
3388 | Helper.applyBuildFnNoErase(*MIs[0], MatchData88); |
3389 | return true; |
3390 | } |
3391 | } |
3392 | // Leaf name: combine_fsub_fmul_to_fmad_or_fma |
3393 | // Rule: combine_fsub_fmul_to_fmad_or_fma |
3394 | if (!RuleConfig->isRuleDisabled(94)) { |
3395 | if (1 |
3396 | && [&]() { |
3397 | return Helper.matchCombineFSubFMulToFMadOrFMA(*MIs[0], |
3398 | MatchData94); |
3399 | return true; |
3400 | }()) { |
3401 | Helper.applyBuildFn(*MIs[0], MatchData94); |
3402 | return true; |
3403 | } |
3404 | } |
3405 | // Leaf name: combine_fsub_fneg_fmul_to_fmad_or_fma |
3406 | // Rule: combine_fsub_fneg_fmul_to_fmad_or_fma |
3407 | if (!RuleConfig->isRuleDisabled(95)) { |
3408 | if (1 |
3409 | && [&]() { |
3410 | return Helper.matchCombineFSubFNegFMulToFMadOrFMA(*MIs[0], |
3411 | MatchData95); |
3412 | return true; |
3413 | }()) { |
3414 | Helper.applyBuildFn(*MIs[0], MatchData95); |
3415 | return true; |
3416 | } |
3417 | } |
3418 | // Leaf name: combine_fsub_fpext_fmul_to_fmad_or_fma |
3419 | // Rule: combine_fsub_fpext_fmul_to_fmad_or_fma |
3420 | if (!RuleConfig->isRuleDisabled(96)) { |
3421 | if (1 |
3422 | && [&]() { |
3423 | return Helper.matchCombineFSubFpExtFMulToFMadOrFMA(*MIs[0], |
3424 | MatchData96); |
3425 | return true; |
3426 | }()) { |
3427 | Helper.applyBuildFn(*MIs[0], MatchData96); |
3428 | return true; |
3429 | } |
3430 | } |
3431 | // Leaf name: combine_fsub_fpext_fneg_fmul_to_fmad_or_fma |
3432 | // Rule: combine_fsub_fpext_fneg_fmul_to_fmad_or_fma |
3433 | if (!RuleConfig->isRuleDisabled(97)) { |
3434 | if (1 |
3435 | && [&]() { |
3436 | return Helper.matchCombineFSubFpExtFNegFMulToFMadOrFMA( |
3437 | *MIs[0], MatchData97); |
3438 | return true; |
3439 | }()) { |
3440 | Helper.applyBuildFn(*MIs[0], MatchData97); |
3441 | return true; |
3442 | } |
3443 | } |
3444 | // Leaf name: fold_binop_into_select |
3445 | // Rule: fold_binop_into_select |
3446 | if (!RuleConfig->isRuleDisabled(98)) { |
3447 | if (1 |
3448 | && [&]() { |
3449 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3450 | return true; |
3451 | }()) { |
3452 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3453 | return true; |
3454 | } |
3455 | } |
3456 | return false; |
3457 | } |
3458 | if (Partition == 66 /* TargetOpcode::G_FMUL */) { |
3459 | // Leaf name: redundant_neg_operands |
3460 | // Rule: redundant_neg_operands |
3461 | if (!RuleConfig->isRuleDisabled(88)) { |
3462 | if (1 |
3463 | && [&]() { |
3464 | return Helper.matchRedundantNegOperands(*MIs[0], MatchData88); |
3465 | return true; |
3466 | }()) { |
3467 | Helper.applyBuildFnNoErase(*MIs[0], MatchData88); |
3468 | return true; |
3469 | } |
3470 | } |
3471 | // Leaf name: fold_binop_into_select |
3472 | // Rule: fold_binop_into_select |
3473 | if (!RuleConfig->isRuleDisabled(98)) { |
3474 | if (1 |
3475 | && [&]() { |
3476 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3477 | return true; |
3478 | }()) { |
3479 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3480 | return true; |
3481 | } |
3482 | } |
3483 | return false; |
3484 | } |
3485 | if (Partition == 67 /* TargetOpcode::G_FDIV */) { |
3486 | // Leaf name: redundant_neg_operands |
3487 | // Rule: redundant_neg_operands |
3488 | if (!RuleConfig->isRuleDisabled(88)) { |
3489 | if (1 |
3490 | && [&]() { |
3491 | return Helper.matchRedundantNegOperands(*MIs[0], MatchData88); |
3492 | return true; |
3493 | }()) { |
3494 | Helper.applyBuildFnNoErase(*MIs[0], MatchData88); |
3495 | return true; |
3496 | } |
3497 | } |
3498 | // Leaf name: fold_binop_into_select |
3499 | // Rule: fold_binop_into_select |
3500 | if (!RuleConfig->isRuleDisabled(98)) { |
3501 | if (1 |
3502 | && [&]() { |
3503 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3504 | return true; |
3505 | }()) { |
3506 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3507 | return true; |
3508 | } |
3509 | } |
3510 | return false; |
3511 | } |
3512 | if (Partition == 68 /* TargetOpcode::G_FMAD */) { |
3513 | // Leaf name: redundant_neg_operands |
3514 | // Rule: redundant_neg_operands |
3515 | if (!RuleConfig->isRuleDisabled(88)) { |
3516 | if (1 |
3517 | && [&]() { |
3518 | return Helper.matchRedundantNegOperands(*MIs[0], MatchData88); |
3519 | return true; |
3520 | }()) { |
3521 | Helper.applyBuildFnNoErase(*MIs[0], MatchData88); |
3522 | return true; |
3523 | } |
3524 | } |
3525 | return false; |
3526 | } |
3527 | if (Partition == 69 /* TargetOpcode::G_FMA */) { |
3528 | // Leaf name: redundant_neg_operands |
3529 | // Rule: redundant_neg_operands |
3530 | if (!RuleConfig->isRuleDisabled(88)) { |
3531 | if (1 |
3532 | && [&]() { |
3533 | return Helper.matchRedundantNegOperands(*MIs[0], MatchData88); |
3534 | return true; |
3535 | }()) { |
3536 | Helper.applyBuildFnNoErase(*MIs[0], MatchData88); |
3537 | return true; |
3538 | } |
3539 | } |
3540 | return false; |
3541 | } |
3542 | if (Partition == 70 /* TargetOpcode::G_SMIN */) { |
3543 | // Leaf name: fold_binop_into_select |
3544 | // Rule: fold_binop_into_select |
3545 | if (!RuleConfig->isRuleDisabled(98)) { |
3546 | if (1 |
3547 | && [&]() { |
3548 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3549 | return true; |
3550 | }()) { |
3551 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3552 | return true; |
3553 | } |
3554 | } |
3555 | return false; |
3556 | } |
3557 | if (Partition == 71 /* TargetOpcode::G_SMAX */) { |
3558 | // Leaf name: fold_binop_into_select |
3559 | // Rule: fold_binop_into_select |
3560 | if (!RuleConfig->isRuleDisabled(98)) { |
3561 | if (1 |
3562 | && [&]() { |
3563 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3564 | return true; |
3565 | }()) { |
3566 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3567 | return true; |
3568 | } |
3569 | } |
3570 | return false; |
3571 | } |
3572 | if (Partition == 72 /* TargetOpcode::G_UMIN */) { |
3573 | // Leaf name: fold_binop_into_select |
3574 | // Rule: fold_binop_into_select |
3575 | if (!RuleConfig->isRuleDisabled(98)) { |
3576 | if (1 |
3577 | && [&]() { |
3578 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3579 | return true; |
3580 | }()) { |
3581 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3582 | return true; |
3583 | } |
3584 | } |
3585 | return false; |
3586 | } |
3587 | if (Partition == 73 /* TargetOpcode::G_UMAX */) { |
3588 | // Leaf name: fold_binop_into_select |
3589 | // Rule: fold_binop_into_select |
3590 | if (!RuleConfig->isRuleDisabled(98)) { |
3591 | if (1 |
3592 | && [&]() { |
3593 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3594 | return true; |
3595 | }()) { |
3596 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3597 | return true; |
3598 | } |
3599 | } |
3600 | return false; |
3601 | } |
3602 | if (Partition == 74 /* TargetOpcode::G_FREM */) { |
3603 | // Leaf name: fold_binop_into_select |
3604 | // Rule: fold_binop_into_select |
3605 | if (!RuleConfig->isRuleDisabled(98)) { |
3606 | if (1 |
3607 | && [&]() { |
3608 | return Helper.matchFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3609 | return true; |
3610 | }()) { |
3611 | return Helper.applyFoldBinOpIntoSelect(*MIs[0], MatchData98); |
3612 | return true; |
3613 | } |
3614 | } |
3615 | return false; |
3616 | } |
3617 | if (Partition == 75 /* TargetOpcode::G_FCONSTANT */) { |
3618 | // Leaf name: fconstant_to_constant |
3619 | // Rule: fconstant_to_constant |
3620 | if (!RuleConfig->isRuleDisabled(99)) { |
3621 | if (1 |
3622 | && [&]() { |
3623 | return matchFConstantToConstant(*MIs[0], MRI); |
3624 | return true; |
3625 | }()) { |
3626 | applyFConstantToConstant(*MIs[0]); |
3627 | return true; |
3628 | } |
3629 | } |
3630 | return false; |
3631 | } |
3632 | if (Partition == 76 /* TargetOpcode::G_GLOBAL_VALUE */) { |
3633 | // Leaf name: fold_global_offset |
3634 | // Rule: fold_global_offset |
3635 | if (!RuleConfig->isRuleDisabled(101)) { |
3636 | if (1 |
3637 | && [&]() { |
3638 | return matchFoldGlobalOffset(*MIs[0], MRI, MatchData101); |
3639 | return true; |
3640 | }()) { |
3641 | return applyFoldGlobalOffset(*MIs[0], MRI, B, Observer, MatchData101); |
3642 | return true; |
3643 | } |
3644 | } |
3645 | return false; |
3646 | } |
3647 | |
3648 | return false; |
3649 | } |
3650 | #endif // ifdef AARCH64PRELEGALIZERCOMBINERHELPER_GENCOMBINERHELPER_CPP |