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