Bug Summary

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