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