Bug Summary

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