Bug Summary

File:build/source/build-llvm/tools/clang/stage2-bins/lib/Target/AMDGPU/AMDGPUGenPreLegalizeGICombiner.inc
Warning:line 3033, column 7
Value stored to 'Partition' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

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