1 #include "bifrost_nir.h"
2 
3 #include "nir.h"
4 #include "nir_builder.h"
5 #include "nir_search.h"
6 #include "nir_search_helpers.h"
7 
8 /* What follows is NIR algebraic transform code for the following 79
9  * transforms:
10  *    ('ineg', 'a') => ('isub', 0, 'a')
11  *    ('b2f16', 'a@8') => ('b8csel', 'a', 1.0, 0.0)
12  *    ('b2f32', 'a@8') => ('b8csel', 'a', 1.0, 0.0)
13  *    ('b2f64', 'a@8') => ('b8csel', 'a', 1.0, 0.0)
14  *    ('b2f16', 'a@16') => ('b16csel', 'a', 1.0, 0.0)
15  *    ('b2f32', 'a@16') => ('b16csel', 'a', 1.0, 0.0)
16  *    ('b2f64', 'a@16') => ('b16csel', 'a', 1.0, 0.0)
17  *    ('b2f16', 'a@32') => ('b32csel', 'a', 1.0, 0.0)
18  *    ('b2f32', 'a@32') => ('b32csel', 'a', 1.0, 0.0)
19  *    ('b2f64', 'a@32') => ('b32csel', 'a', 1.0, 0.0)
20  *    ('imin', 'a@8', 'b@8') => ('b8csel', ('ilt8', 'a', 'b'), 'a', 'b')
21  *    ('imax', 'a@8', 'b@8') => ('b8csel', ('ilt8', 'b', 'a'), 'a', 'b')
22  *    ('umin', 'a@8', 'b@8') => ('b8csel', ('ult8', 'a', 'b'), 'a', 'b')
23  *    ('umax', 'a@8', 'b@8') => ('b8csel', ('ult8', 'b', 'a'), 'a', 'b')
24  *    ('imin', 'a@16', 'b@16') => ('b16csel', ('ilt16', 'a', 'b'), 'a', 'b')
25  *    ('imax', 'a@16', 'b@16') => ('b16csel', ('ilt16', 'b', 'a'), 'a', 'b')
26  *    ('umin', 'a@16', 'b@16') => ('b16csel', ('ult16', 'a', 'b'), 'a', 'b')
27  *    ('umax', 'a@16', 'b@16') => ('b16csel', ('ult16', 'b', 'a'), 'a', 'b')
28  *    ('imin', 'a@32', 'b@32') => ('b32csel', ('ilt32', 'a', 'b'), 'a', 'b')
29  *    ('imax', 'a@32', 'b@32') => ('b32csel', ('ilt32', 'b', 'a'), 'a', 'b')
30  *    ('umin', 'a@32', 'b@32') => ('b32csel', ('ult32', 'a', 'b'), 'a', 'b')
31  *    ('umax', 'a@32', 'b@32') => ('b32csel', ('ult32', 'b', 'a'), 'a', 'b')
32  *    ('u2u8', 'a@32') => ('u2u8', ('u2u16', 'a'))
33  *    ('u2u8', 'a@64') => ('u2u8', ('u2u16', ('u2u32', 'a')))
34  *    ('u2u16', 'a@64') => ('u2u16', ('u2u32', 'a'))
35  *    ('u2u32', 'a@8') => ('u2u32', ('u2u16', 'a'))
36  *    ('u2u64', 'a@8') => ('u2u64', ('u2u32', ('u2u16', 'a')))
37  *    ('u2u64', 'a@16') => ('u2u64', ('u2u32', 'a'))
38  *    ('i2i8', 'a@32') => ('i2i8', ('i2i16', 'a'))
39  *    ('i2i8', 'a@64') => ('i2i8', ('i2i16', ('i2i32', 'a')))
40  *    ('i2i16', 'a@64') => ('i2i16', ('i2i32', 'a'))
41  *    ('i2i32', 'a@8') => ('i2i32', ('i2i16', 'a'))
42  *    ('i2i64', 'a@8') => ('i2i64', ('i2i32', ('i2i16', 'a')))
43  *    ('i2i64', 'a@16') => ('i2i64', ('i2i32', 'a'))
44  *    ('f2f16', 'a@64') => ('f2f16', ('f2f32', 'a'))
45  *    ('f2f64', 'a@16') => ('f2f64', ('f2f32', 'a'))
46  *    ('i2f16', 'a@8') => ('i2f16', ('i2i16', 'a'))
47  *    ('i2f16', 'a@32') => ('f2f16', ('i2f32', 'a'))
48  *    ('i2f16', 'a@64') => ('f2f16', ('f2f32', ('i2f64', 'a')))
49  *    ('i2f32', 'a@8') => ('i2f32', ('i2i32', ('i2i16', 'a')))
50  *    ('i2f32', 'a@16') => ('i2f32', ('i2i32', 'a'))
51  *    ('i2f32', 'a@64') => ('f2f32', ('i2f64', 'a'))
52  *    ('i2f64', 'a@8') => ('i2f64', ('i2i64', ('i2i32', ('i2i16', 'a'))))
53  *    ('i2f64', 'a@16') => ('i2f64', ('i2i64', ('i2i32', 'a')))
54  *    ('i2f64', 'a@32') => ('i2f64', ('i2i64', 'a'))
55  *    ('u2f16', 'a@8') => ('u2f16', ('u2u16', 'a'))
56  *    ('u2f16', 'a@32') => ('f2f16', ('u2f32', 'a'))
57  *    ('u2f16', 'a@64') => ('f2f16', ('f2f32', ('u2f64', 'a')))
58  *    ('u2f32', 'a@8') => ('u2f32', ('u2u32', ('u2u16', 'a')))
59  *    ('u2f32', 'a@16') => ('u2f32', ('u2u32', 'a'))
60  *    ('u2f32', 'a@64') => ('f2f32', ('u2f64', 'a'))
61  *    ('u2f64', 'a@8') => ('u2f64', ('u2u64', ('u2u32', ('u2u16', 'a'))))
62  *    ('u2f64', 'a@16') => ('u2f64', ('u2u64', ('u2u32', 'a')))
63  *    ('u2f64', 'a@32') => ('u2f64', ('u2u64', 'a'))
64  *    ('f2i8', 'a@16') => ('i2i8', ('f2i16', 'a'))
65  *    ('f2i8', 'a@32') => ('i2i8', ('i2i16', ('f2i32', 'a')))
66  *    ('f2i8', 'a@64') => ('i2i8', ('i2i16', ('i2i32', ('f2i64', 'a'))))
67  *    ('f2i16', 'a@32') => ('i2i16', ('f2i32', 'a'))
68  *    ('f2i16', 'a@64') => ('i2i16', ('i2i32', ('f2i64', 'a')))
69  *    ('f2i32', 'a@16') => ('f2i32', ('f2f32', 'a'))
70  *    ('f2i32', 'a@64') => ('i2i32', ('f2i64', 'a'))
71  *    ('f2i64', 'a@16') => ('f2i64', ('f2f64', ('f2f32', 'a')))
72  *    ('f2i64', 'a@32') => ('f2i64', ('f2f64', 'a'))
73  *    ('f2u8', 'a@16') => ('u2u8', ('f2u16', 'a'))
74  *    ('f2u8', 'a@32') => ('u2u8', ('u2u16', ('f2u32', 'a')))
75  *    ('f2u8', 'a@64') => ('u2u8', ('u2u16', ('u2u32', ('f2u64', 'a'))))
76  *    ('f2u16', 'a@32') => ('u2u16', ('f2u32', 'a'))
77  *    ('f2u16', 'a@64') => ('u2u16', ('u2u32', ('f2u64', 'a')))
78  *    ('f2u32', 'a@16') => ('f2u32', ('f2f32', 'a'))
79  *    ('f2u32', 'a@64') => ('u2u32', ('f2u64', 'a'))
80  *    ('f2u64', 'a@16') => ('f2u64', ('f2f64', ('f2f32', 'a')))
81  *    ('f2u64', 'a@32') => ('f2u64', ('f2f64', 'a'))
82  *    ('fexp2@16', 'a') => ('f2f16', ('fexp2', ('f2f32', 'a')))
83  *    ('flog2@16', 'a') => ('f2f16', ('flog2', ('f2f32', 'a')))
84  *    ('fsin@16', 'a') => ('f2f16', ('fsin', ('f2f32', 'a')))
85  *    ('fcos@16', 'a') => ('f2f16', ('fcos', ('f2f32', 'a')))
86  *    ('f2b32', 'a') => ('fneu32', 'a', 0.0)
87  *    ('i2b32', 'a') => ('ine32', 'a', 0)
88  *    ('b2i32', 'a') => ('iand', 'a@32', 1)
89  */
90 
91 
92    static const nir_search_variable search0_0 = {
93    { nir_search_value_variable, -1 },
94    0, /* a */
95    false,
96    nir_type_invalid,
97    NULL,
98    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
99 };
100 static const nir_search_expression search0 = {
101    { nir_search_value_expression, -1 },
102    false, false,
103    -1, 0,
104    nir_op_ineg,
105    { &search0_0.value },
106    NULL,
107 };
108 
109    static const nir_search_constant replace0_0 = {
110    { nir_search_value_constant, -1 },
111    nir_type_int, { 0x0 /* 0 */ },
112 };
113 
114 /* replace0_1 -> search0_0 in the cache */
115 static const nir_search_expression replace0 = {
116    { nir_search_value_expression, -1 },
117    false, false,
118    -1, 0,
119    nir_op_isub,
120    { &replace0_0.value, &search0_0.value },
121    NULL,
122 };
123 
124    static const nir_search_variable search1_0 = {
125    { nir_search_value_variable, 8 },
126    0, /* a */
127    false,
128    nir_type_invalid,
129    NULL,
130    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
131 };
132 static const nir_search_expression search1 = {
133    { nir_search_value_expression, 16 },
134    false, false,
135    -1, 0,
136    nir_op_b2f16,
137    { &search1_0.value },
138    NULL,
139 };
140 
141    /* replace1_0 -> search1_0 in the cache */
142 
143 static const nir_search_constant replace1_1 = {
144    { nir_search_value_constant, 16 },
145    nir_type_float, { 0x3ff0000000000000 /* 1.0 */ },
146 };
147 
148 static const nir_search_constant replace1_2 = {
149    { nir_search_value_constant, 16 },
150    nir_type_float, { 0x0 /* 0.0 */ },
151 };
152 static const nir_search_expression replace1 = {
153    { nir_search_value_expression, 16 },
154    false, false,
155    -1, 0,
156    nir_op_b8csel,
157    { &search1_0.value, &replace1_1.value, &replace1_2.value },
158    NULL,
159 };
160 
161    /* search2_0 -> search1_0 in the cache */
162 static const nir_search_expression search2 = {
163    { nir_search_value_expression, 32 },
164    false, false,
165    -1, 0,
166    nir_op_b2f32,
167    { &search1_0.value },
168    NULL,
169 };
170 
171    /* replace2_0 -> search1_0 in the cache */
172 
173 static const nir_search_constant replace2_1 = {
174    { nir_search_value_constant, 32 },
175    nir_type_float, { 0x3ff0000000000000 /* 1.0 */ },
176 };
177 
178 static const nir_search_constant replace2_2 = {
179    { nir_search_value_constant, 32 },
180    nir_type_float, { 0x0 /* 0.0 */ },
181 };
182 static const nir_search_expression replace2 = {
183    { nir_search_value_expression, 32 },
184    false, false,
185    -1, 0,
186    nir_op_b8csel,
187    { &search1_0.value, &replace2_1.value, &replace2_2.value },
188    NULL,
189 };
190 
191    /* search3_0 -> search1_0 in the cache */
192 static const nir_search_expression search3 = {
193    { nir_search_value_expression, 64 },
194    false, false,
195    -1, 0,
196    nir_op_b2f64,
197    { &search1_0.value },
198    NULL,
199 };
200 
201    /* replace3_0 -> search1_0 in the cache */
202 
203 static const nir_search_constant replace3_1 = {
204    { nir_search_value_constant, 64 },
205    nir_type_float, { 0x3ff0000000000000 /* 1.0 */ },
206 };
207 
208 static const nir_search_constant replace3_2 = {
209    { nir_search_value_constant, 64 },
210    nir_type_float, { 0x0 /* 0.0 */ },
211 };
212 static const nir_search_expression replace3 = {
213    { nir_search_value_expression, 64 },
214    false, false,
215    -1, 0,
216    nir_op_b8csel,
217    { &search1_0.value, &replace3_1.value, &replace3_2.value },
218    NULL,
219 };
220 
221    static const nir_search_variable search4_0 = {
222    { nir_search_value_variable, 16 },
223    0, /* a */
224    false,
225    nir_type_invalid,
226    NULL,
227    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
228 };
229 static const nir_search_expression search4 = {
230    { nir_search_value_expression, 16 },
231    false, false,
232    -1, 0,
233    nir_op_b2f16,
234    { &search4_0.value },
235    NULL,
236 };
237 
238    /* replace4_0 -> search4_0 in the cache */
239 
240 /* replace4_1 -> replace1_1 in the cache */
241 
242 /* replace4_2 -> replace1_2 in the cache */
243 static const nir_search_expression replace4 = {
244    { nir_search_value_expression, 16 },
245    false, false,
246    -1, 0,
247    nir_op_b16csel,
248    { &search4_0.value, &replace1_1.value, &replace1_2.value },
249    NULL,
250 };
251 
252    /* search5_0 -> search4_0 in the cache */
253 static const nir_search_expression search5 = {
254    { nir_search_value_expression, 32 },
255    false, false,
256    -1, 0,
257    nir_op_b2f32,
258    { &search4_0.value },
259    NULL,
260 };
261 
262    /* replace5_0 -> search4_0 in the cache */
263 
264 /* replace5_1 -> replace2_1 in the cache */
265 
266 /* replace5_2 -> replace2_2 in the cache */
267 static const nir_search_expression replace5 = {
268    { nir_search_value_expression, 32 },
269    false, false,
270    -1, 0,
271    nir_op_b16csel,
272    { &search4_0.value, &replace2_1.value, &replace2_2.value },
273    NULL,
274 };
275 
276    /* search6_0 -> search4_0 in the cache */
277 static const nir_search_expression search6 = {
278    { nir_search_value_expression, 64 },
279    false, false,
280    -1, 0,
281    nir_op_b2f64,
282    { &search4_0.value },
283    NULL,
284 };
285 
286    /* replace6_0 -> search4_0 in the cache */
287 
288 /* replace6_1 -> replace3_1 in the cache */
289 
290 /* replace6_2 -> replace3_2 in the cache */
291 static const nir_search_expression replace6 = {
292    { nir_search_value_expression, 64 },
293    false, false,
294    -1, 0,
295    nir_op_b16csel,
296    { &search4_0.value, &replace3_1.value, &replace3_2.value },
297    NULL,
298 };
299 
300    static const nir_search_variable search7_0 = {
301    { nir_search_value_variable, 32 },
302    0, /* a */
303    false,
304    nir_type_invalid,
305    NULL,
306    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
307 };
308 static const nir_search_expression search7 = {
309    { nir_search_value_expression, 16 },
310    false, false,
311    -1, 0,
312    nir_op_b2f16,
313    { &search7_0.value },
314    NULL,
315 };
316 
317    /* replace7_0 -> search7_0 in the cache */
318 
319 /* replace7_1 -> replace1_1 in the cache */
320 
321 /* replace7_2 -> replace1_2 in the cache */
322 static const nir_search_expression replace7 = {
323    { nir_search_value_expression, 16 },
324    false, false,
325    -1, 0,
326    nir_op_b32csel,
327    { &search7_0.value, &replace1_1.value, &replace1_2.value },
328    NULL,
329 };
330 
331    /* search8_0 -> search7_0 in the cache */
332 static const nir_search_expression search8 = {
333    { nir_search_value_expression, 32 },
334    false, false,
335    -1, 0,
336    nir_op_b2f32,
337    { &search7_0.value },
338    NULL,
339 };
340 
341    /* replace8_0 -> search7_0 in the cache */
342 
343 /* replace8_1 -> replace2_1 in the cache */
344 
345 /* replace8_2 -> replace2_2 in the cache */
346 static const nir_search_expression replace8 = {
347    { nir_search_value_expression, 32 },
348    false, false,
349    -1, 0,
350    nir_op_b32csel,
351    { &search7_0.value, &replace2_1.value, &replace2_2.value },
352    NULL,
353 };
354 
355    /* search9_0 -> search7_0 in the cache */
356 static const nir_search_expression search9 = {
357    { nir_search_value_expression, 64 },
358    false, false,
359    -1, 0,
360    nir_op_b2f64,
361    { &search7_0.value },
362    NULL,
363 };
364 
365    /* replace9_0 -> search7_0 in the cache */
366 
367 /* replace9_1 -> replace3_1 in the cache */
368 
369 /* replace9_2 -> replace3_2 in the cache */
370 static const nir_search_expression replace9 = {
371    { nir_search_value_expression, 64 },
372    false, false,
373    -1, 0,
374    nir_op_b32csel,
375    { &search7_0.value, &replace3_1.value, &replace3_2.value },
376    NULL,
377 };
378 
379    /* search10_0 -> search1_0 in the cache */
380 
381 static const nir_search_variable search10_1 = {
382    { nir_search_value_variable, 8 },
383    1, /* b */
384    false,
385    nir_type_invalid,
386    NULL,
387    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
388 };
389 static const nir_search_expression search10 = {
390    { nir_search_value_expression, 8 },
391    false, false,
392    0, 1,
393    nir_op_imin,
394    { &search1_0.value, &search10_1.value },
395    NULL,
396 };
397 
398    /* replace10_0_0 -> search1_0 in the cache */
399 
400 /* replace10_0_1 -> search10_1 in the cache */
401 static const nir_search_expression replace10_0 = {
402    { nir_search_value_expression, 8 },
403    false, false,
404    -1, 0,
405    nir_op_ilt8,
406    { &search1_0.value, &search10_1.value },
407    NULL,
408 };
409 
410 /* replace10_1 -> search1_0 in the cache */
411 
412 /* replace10_2 -> search10_1 in the cache */
413 static const nir_search_expression replace10 = {
414    { nir_search_value_expression, 8 },
415    false, false,
416    -1, 0,
417    nir_op_b8csel,
418    { &replace10_0.value, &search1_0.value, &search10_1.value },
419    NULL,
420 };
421 
422    /* search11_0 -> search1_0 in the cache */
423 
424 /* search11_1 -> search10_1 in the cache */
425 static const nir_search_expression search11 = {
426    { nir_search_value_expression, 8 },
427    false, false,
428    0, 1,
429    nir_op_imax,
430    { &search1_0.value, &search10_1.value },
431    NULL,
432 };
433 
434    /* replace11_0_0 -> search10_1 in the cache */
435 
436 /* replace11_0_1 -> search1_0 in the cache */
437 static const nir_search_expression replace11_0 = {
438    { nir_search_value_expression, 8 },
439    false, false,
440    -1, 0,
441    nir_op_ilt8,
442    { &search10_1.value, &search1_0.value },
443    NULL,
444 };
445 
446 /* replace11_1 -> search1_0 in the cache */
447 
448 /* replace11_2 -> search10_1 in the cache */
449 static const nir_search_expression replace11 = {
450    { nir_search_value_expression, 8 },
451    false, false,
452    -1, 0,
453    nir_op_b8csel,
454    { &replace11_0.value, &search1_0.value, &search10_1.value },
455    NULL,
456 };
457 
458    /* search12_0 -> search1_0 in the cache */
459 
460 /* search12_1 -> search10_1 in the cache */
461 static const nir_search_expression search12 = {
462    { nir_search_value_expression, 8 },
463    false, false,
464    0, 1,
465    nir_op_umin,
466    { &search1_0.value, &search10_1.value },
467    NULL,
468 };
469 
470    /* replace12_0_0 -> search1_0 in the cache */
471 
472 /* replace12_0_1 -> search10_1 in the cache */
473 static const nir_search_expression replace12_0 = {
474    { nir_search_value_expression, 8 },
475    false, false,
476    -1, 0,
477    nir_op_ult8,
478    { &search1_0.value, &search10_1.value },
479    NULL,
480 };
481 
482 /* replace12_1 -> search1_0 in the cache */
483 
484 /* replace12_2 -> search10_1 in the cache */
485 static const nir_search_expression replace12 = {
486    { nir_search_value_expression, 8 },
487    false, false,
488    -1, 0,
489    nir_op_b8csel,
490    { &replace12_0.value, &search1_0.value, &search10_1.value },
491    NULL,
492 };
493 
494    /* search13_0 -> search1_0 in the cache */
495 
496 /* search13_1 -> search10_1 in the cache */
497 static const nir_search_expression search13 = {
498    { nir_search_value_expression, 8 },
499    false, false,
500    0, 1,
501    nir_op_umax,
502    { &search1_0.value, &search10_1.value },
503    NULL,
504 };
505 
506    /* replace13_0_0 -> search10_1 in the cache */
507 
508 /* replace13_0_1 -> search1_0 in the cache */
509 static const nir_search_expression replace13_0 = {
510    { nir_search_value_expression, 8 },
511    false, false,
512    -1, 0,
513    nir_op_ult8,
514    { &search10_1.value, &search1_0.value },
515    NULL,
516 };
517 
518 /* replace13_1 -> search1_0 in the cache */
519 
520 /* replace13_2 -> search10_1 in the cache */
521 static const nir_search_expression replace13 = {
522    { nir_search_value_expression, 8 },
523    false, false,
524    -1, 0,
525    nir_op_b8csel,
526    { &replace13_0.value, &search1_0.value, &search10_1.value },
527    NULL,
528 };
529 
530    /* search14_0 -> search4_0 in the cache */
531 
532 static const nir_search_variable search14_1 = {
533    { nir_search_value_variable, 16 },
534    1, /* b */
535    false,
536    nir_type_invalid,
537    NULL,
538    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
539 };
540 static const nir_search_expression search14 = {
541    { nir_search_value_expression, 16 },
542    false, false,
543    0, 1,
544    nir_op_imin,
545    { &search4_0.value, &search14_1.value },
546    NULL,
547 };
548 
549    /* replace14_0_0 -> search4_0 in the cache */
550 
551 /* replace14_0_1 -> search14_1 in the cache */
552 static const nir_search_expression replace14_0 = {
553    { nir_search_value_expression, 16 },
554    false, false,
555    -1, 0,
556    nir_op_ilt16,
557    { &search4_0.value, &search14_1.value },
558    NULL,
559 };
560 
561 /* replace14_1 -> search4_0 in the cache */
562 
563 /* replace14_2 -> search14_1 in the cache */
564 static const nir_search_expression replace14 = {
565    { nir_search_value_expression, 16 },
566    false, false,
567    -1, 0,
568    nir_op_b16csel,
569    { &replace14_0.value, &search4_0.value, &search14_1.value },
570    NULL,
571 };
572 
573    /* search15_0 -> search4_0 in the cache */
574 
575 /* search15_1 -> search14_1 in the cache */
576 static const nir_search_expression search15 = {
577    { nir_search_value_expression, 16 },
578    false, false,
579    0, 1,
580    nir_op_imax,
581    { &search4_0.value, &search14_1.value },
582    NULL,
583 };
584 
585    /* replace15_0_0 -> search14_1 in the cache */
586 
587 /* replace15_0_1 -> search4_0 in the cache */
588 static const nir_search_expression replace15_0 = {
589    { nir_search_value_expression, 16 },
590    false, false,
591    -1, 0,
592    nir_op_ilt16,
593    { &search14_1.value, &search4_0.value },
594    NULL,
595 };
596 
597 /* replace15_1 -> search4_0 in the cache */
598 
599 /* replace15_2 -> search14_1 in the cache */
600 static const nir_search_expression replace15 = {
601    { nir_search_value_expression, 16 },
602    false, false,
603    -1, 0,
604    nir_op_b16csel,
605    { &replace15_0.value, &search4_0.value, &search14_1.value },
606    NULL,
607 };
608 
609    /* search16_0 -> search4_0 in the cache */
610 
611 /* search16_1 -> search14_1 in the cache */
612 static const nir_search_expression search16 = {
613    { nir_search_value_expression, 16 },
614    false, false,
615    0, 1,
616    nir_op_umin,
617    { &search4_0.value, &search14_1.value },
618    NULL,
619 };
620 
621    /* replace16_0_0 -> search4_0 in the cache */
622 
623 /* replace16_0_1 -> search14_1 in the cache */
624 static const nir_search_expression replace16_0 = {
625    { nir_search_value_expression, 16 },
626    false, false,
627    -1, 0,
628    nir_op_ult16,
629    { &search4_0.value, &search14_1.value },
630    NULL,
631 };
632 
633 /* replace16_1 -> search4_0 in the cache */
634 
635 /* replace16_2 -> search14_1 in the cache */
636 static const nir_search_expression replace16 = {
637    { nir_search_value_expression, 16 },
638    false, false,
639    -1, 0,
640    nir_op_b16csel,
641    { &replace16_0.value, &search4_0.value, &search14_1.value },
642    NULL,
643 };
644 
645    /* search17_0 -> search4_0 in the cache */
646 
647 /* search17_1 -> search14_1 in the cache */
648 static const nir_search_expression search17 = {
649    { nir_search_value_expression, 16 },
650    false, false,
651    0, 1,
652    nir_op_umax,
653    { &search4_0.value, &search14_1.value },
654    NULL,
655 };
656 
657    /* replace17_0_0 -> search14_1 in the cache */
658 
659 /* replace17_0_1 -> search4_0 in the cache */
660 static const nir_search_expression replace17_0 = {
661    { nir_search_value_expression, 16 },
662    false, false,
663    -1, 0,
664    nir_op_ult16,
665    { &search14_1.value, &search4_0.value },
666    NULL,
667 };
668 
669 /* replace17_1 -> search4_0 in the cache */
670 
671 /* replace17_2 -> search14_1 in the cache */
672 static const nir_search_expression replace17 = {
673    { nir_search_value_expression, 16 },
674    false, false,
675    -1, 0,
676    nir_op_b16csel,
677    { &replace17_0.value, &search4_0.value, &search14_1.value },
678    NULL,
679 };
680 
681    /* search18_0 -> search7_0 in the cache */
682 
683 static const nir_search_variable search18_1 = {
684    { nir_search_value_variable, 32 },
685    1, /* b */
686    false,
687    nir_type_invalid,
688    NULL,
689    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
690 };
691 static const nir_search_expression search18 = {
692    { nir_search_value_expression, 32 },
693    false, false,
694    0, 1,
695    nir_op_imin,
696    { &search7_0.value, &search18_1.value },
697    NULL,
698 };
699 
700    /* replace18_0_0 -> search7_0 in the cache */
701 
702 /* replace18_0_1 -> search18_1 in the cache */
703 static const nir_search_expression replace18_0 = {
704    { nir_search_value_expression, 32 },
705    false, false,
706    -1, 0,
707    nir_op_ilt32,
708    { &search7_0.value, &search18_1.value },
709    NULL,
710 };
711 
712 /* replace18_1 -> search7_0 in the cache */
713 
714 /* replace18_2 -> search18_1 in the cache */
715 static const nir_search_expression replace18 = {
716    { nir_search_value_expression, 32 },
717    false, false,
718    -1, 0,
719    nir_op_b32csel,
720    { &replace18_0.value, &search7_0.value, &search18_1.value },
721    NULL,
722 };
723 
724    /* search19_0 -> search7_0 in the cache */
725 
726 /* search19_1 -> search18_1 in the cache */
727 static const nir_search_expression search19 = {
728    { nir_search_value_expression, 32 },
729    false, false,
730    0, 1,
731    nir_op_imax,
732    { &search7_0.value, &search18_1.value },
733    NULL,
734 };
735 
736    /* replace19_0_0 -> search18_1 in the cache */
737 
738 /* replace19_0_1 -> search7_0 in the cache */
739 static const nir_search_expression replace19_0 = {
740    { nir_search_value_expression, 32 },
741    false, false,
742    -1, 0,
743    nir_op_ilt32,
744    { &search18_1.value, &search7_0.value },
745    NULL,
746 };
747 
748 /* replace19_1 -> search7_0 in the cache */
749 
750 /* replace19_2 -> search18_1 in the cache */
751 static const nir_search_expression replace19 = {
752    { nir_search_value_expression, 32 },
753    false, false,
754    -1, 0,
755    nir_op_b32csel,
756    { &replace19_0.value, &search7_0.value, &search18_1.value },
757    NULL,
758 };
759 
760    /* search20_0 -> search7_0 in the cache */
761 
762 /* search20_1 -> search18_1 in the cache */
763 static const nir_search_expression search20 = {
764    { nir_search_value_expression, 32 },
765    false, false,
766    0, 1,
767    nir_op_umin,
768    { &search7_0.value, &search18_1.value },
769    NULL,
770 };
771 
772    /* replace20_0_0 -> search7_0 in the cache */
773 
774 /* replace20_0_1 -> search18_1 in the cache */
775 static const nir_search_expression replace20_0 = {
776    { nir_search_value_expression, 32 },
777    false, false,
778    -1, 0,
779    nir_op_ult32,
780    { &search7_0.value, &search18_1.value },
781    NULL,
782 };
783 
784 /* replace20_1 -> search7_0 in the cache */
785 
786 /* replace20_2 -> search18_1 in the cache */
787 static const nir_search_expression replace20 = {
788    { nir_search_value_expression, 32 },
789    false, false,
790    -1, 0,
791    nir_op_b32csel,
792    { &replace20_0.value, &search7_0.value, &search18_1.value },
793    NULL,
794 };
795 
796    /* search21_0 -> search7_0 in the cache */
797 
798 /* search21_1 -> search18_1 in the cache */
799 static const nir_search_expression search21 = {
800    { nir_search_value_expression, 32 },
801    false, false,
802    0, 1,
803    nir_op_umax,
804    { &search7_0.value, &search18_1.value },
805    NULL,
806 };
807 
808    /* replace21_0_0 -> search18_1 in the cache */
809 
810 /* replace21_0_1 -> search7_0 in the cache */
811 static const nir_search_expression replace21_0 = {
812    { nir_search_value_expression, 32 },
813    false, false,
814    -1, 0,
815    nir_op_ult32,
816    { &search18_1.value, &search7_0.value },
817    NULL,
818 };
819 
820 /* replace21_1 -> search7_0 in the cache */
821 
822 /* replace21_2 -> search18_1 in the cache */
823 static const nir_search_expression replace21 = {
824    { nir_search_value_expression, 32 },
825    false, false,
826    -1, 0,
827    nir_op_b32csel,
828    { &replace21_0.value, &search7_0.value, &search18_1.value },
829    NULL,
830 };
831 
832    /* search22_0 -> search7_0 in the cache */
833 static const nir_search_expression search22 = {
834    { nir_search_value_expression, 8 },
835    false, false,
836    -1, 0,
837    nir_op_u2u8,
838    { &search7_0.value },
839    NULL,
840 };
841 
842    /* replace22_0_0 -> search7_0 in the cache */
843 static const nir_search_expression replace22_0 = {
844    { nir_search_value_expression, 16 },
845    false, false,
846    -1, 0,
847    nir_op_u2u16,
848    { &search7_0.value },
849    NULL,
850 };
851 static const nir_search_expression replace22 = {
852    { nir_search_value_expression, 8 },
853    false, false,
854    -1, 0,
855    nir_op_u2u8,
856    { &replace22_0.value },
857    NULL,
858 };
859 
860    static const nir_search_variable search23_0 = {
861    { nir_search_value_variable, 64 },
862    0, /* a */
863    false,
864    nir_type_invalid,
865    NULL,
866    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
867 };
868 static const nir_search_expression search23 = {
869    { nir_search_value_expression, 8 },
870    false, false,
871    -1, 0,
872    nir_op_u2u8,
873    { &search23_0.value },
874    NULL,
875 };
876 
877    /* replace23_0_0_0 -> search23_0 in the cache */
878 static const nir_search_expression replace23_0_0 = {
879    { nir_search_value_expression, 32 },
880    false, false,
881    -1, 0,
882    nir_op_u2u32,
883    { &search23_0.value },
884    NULL,
885 };
886 static const nir_search_expression replace23_0 = {
887    { nir_search_value_expression, 16 },
888    false, false,
889    -1, 0,
890    nir_op_u2u16,
891    { &replace23_0_0.value },
892    NULL,
893 };
894 static const nir_search_expression replace23 = {
895    { nir_search_value_expression, 8 },
896    false, false,
897    -1, 0,
898    nir_op_u2u8,
899    { &replace23_0.value },
900    NULL,
901 };
902 
903    /* search24_0 -> search23_0 in the cache */
904 static const nir_search_expression search24 = {
905    { nir_search_value_expression, 16 },
906    false, false,
907    -1, 0,
908    nir_op_u2u16,
909    { &search23_0.value },
910    NULL,
911 };
912 
913    /* replace24_0_0 -> search23_0 in the cache */
914 /* replace24_0 -> replace23_0_0 in the cache */
915 /* replace24 -> replace23_0 in the cache */
916 
917    /* search25_0 -> search1_0 in the cache */
918 static const nir_search_expression search25 = {
919    { nir_search_value_expression, 32 },
920    false, false,
921    -1, 0,
922    nir_op_u2u32,
923    { &search1_0.value },
924    NULL,
925 };
926 
927    /* replace25_0_0 -> search1_0 in the cache */
928 static const nir_search_expression replace25_0 = {
929    { nir_search_value_expression, 16 },
930    false, false,
931    -1, 0,
932    nir_op_u2u16,
933    { &search1_0.value },
934    NULL,
935 };
936 static const nir_search_expression replace25 = {
937    { nir_search_value_expression, 32 },
938    false, false,
939    -1, 0,
940    nir_op_u2u32,
941    { &replace25_0.value },
942    NULL,
943 };
944 
945    /* search26_0 -> search1_0 in the cache */
946 static const nir_search_expression search26 = {
947    { nir_search_value_expression, 64 },
948    false, false,
949    -1, 0,
950    nir_op_u2u64,
951    { &search1_0.value },
952    NULL,
953 };
954 
955    /* replace26_0_0_0 -> search1_0 in the cache */
956 /* replace26_0_0 -> replace25_0 in the cache */
957 /* replace26_0 -> replace25 in the cache */
958 static const nir_search_expression replace26 = {
959    { nir_search_value_expression, 64 },
960    false, false,
961    -1, 0,
962    nir_op_u2u64,
963    { &replace25.value },
964    NULL,
965 };
966 
967    /* search27_0 -> search4_0 in the cache */
968 static const nir_search_expression search27 = {
969    { nir_search_value_expression, 64 },
970    false, false,
971    -1, 0,
972    nir_op_u2u64,
973    { &search4_0.value },
974    NULL,
975 };
976 
977    /* replace27_0_0 -> search4_0 in the cache */
978 static const nir_search_expression replace27_0 = {
979    { nir_search_value_expression, 32 },
980    false, false,
981    -1, 0,
982    nir_op_u2u32,
983    { &search4_0.value },
984    NULL,
985 };
986 static const nir_search_expression replace27 = {
987    { nir_search_value_expression, 64 },
988    false, false,
989    -1, 0,
990    nir_op_u2u64,
991    { &replace27_0.value },
992    NULL,
993 };
994 
995    /* search28_0 -> search7_0 in the cache */
996 static const nir_search_expression search28 = {
997    { nir_search_value_expression, 8 },
998    false, false,
999    -1, 0,
1000    nir_op_i2i8,
1001    { &search7_0.value },
1002    NULL,
1003 };
1004 
1005    /* replace28_0_0 -> search7_0 in the cache */
1006 static const nir_search_expression replace28_0 = {
1007    { nir_search_value_expression, 16 },
1008    false, false,
1009    -1, 0,
1010    nir_op_i2i16,
1011    { &search7_0.value },
1012    NULL,
1013 };
1014 static const nir_search_expression replace28 = {
1015    { nir_search_value_expression, 8 },
1016    false, false,
1017    -1, 0,
1018    nir_op_i2i8,
1019    { &replace28_0.value },
1020    NULL,
1021 };
1022 
1023    /* search29_0 -> search23_0 in the cache */
1024 static const nir_search_expression search29 = {
1025    { nir_search_value_expression, 8 },
1026    false, false,
1027    -1, 0,
1028    nir_op_i2i8,
1029    { &search23_0.value },
1030    NULL,
1031 };
1032 
1033    /* replace29_0_0_0 -> search23_0 in the cache */
1034 static const nir_search_expression replace29_0_0 = {
1035    { nir_search_value_expression, 32 },
1036    false, false,
1037    -1, 0,
1038    nir_op_i2i32,
1039    { &search23_0.value },
1040    NULL,
1041 };
1042 static const nir_search_expression replace29_0 = {
1043    { nir_search_value_expression, 16 },
1044    false, false,
1045    -1, 0,
1046    nir_op_i2i16,
1047    { &replace29_0_0.value },
1048    NULL,
1049 };
1050 static const nir_search_expression replace29 = {
1051    { nir_search_value_expression, 8 },
1052    false, false,
1053    -1, 0,
1054    nir_op_i2i8,
1055    { &replace29_0.value },
1056    NULL,
1057 };
1058 
1059    /* search30_0 -> search23_0 in the cache */
1060 static const nir_search_expression search30 = {
1061    { nir_search_value_expression, 16 },
1062    false, false,
1063    -1, 0,
1064    nir_op_i2i16,
1065    { &search23_0.value },
1066    NULL,
1067 };
1068 
1069    /* replace30_0_0 -> search23_0 in the cache */
1070 /* replace30_0 -> replace29_0_0 in the cache */
1071 /* replace30 -> replace29_0 in the cache */
1072 
1073    /* search31_0 -> search1_0 in the cache */
1074 static const nir_search_expression search31 = {
1075    { nir_search_value_expression, 32 },
1076    false, false,
1077    -1, 0,
1078    nir_op_i2i32,
1079    { &search1_0.value },
1080    NULL,
1081 };
1082 
1083    /* replace31_0_0 -> search1_0 in the cache */
1084 static const nir_search_expression replace31_0 = {
1085    { nir_search_value_expression, 16 },
1086    false, false,
1087    -1, 0,
1088    nir_op_i2i16,
1089    { &search1_0.value },
1090    NULL,
1091 };
1092 static const nir_search_expression replace31 = {
1093    { nir_search_value_expression, 32 },
1094    false, false,
1095    -1, 0,
1096    nir_op_i2i32,
1097    { &replace31_0.value },
1098    NULL,
1099 };
1100 
1101    /* search32_0 -> search1_0 in the cache */
1102 static const nir_search_expression search32 = {
1103    { nir_search_value_expression, 64 },
1104    false, false,
1105    -1, 0,
1106    nir_op_i2i64,
1107    { &search1_0.value },
1108    NULL,
1109 };
1110 
1111    /* replace32_0_0_0 -> search1_0 in the cache */
1112 /* replace32_0_0 -> replace31_0 in the cache */
1113 /* replace32_0 -> replace31 in the cache */
1114 static const nir_search_expression replace32 = {
1115    { nir_search_value_expression, 64 },
1116    false, false,
1117    -1, 0,
1118    nir_op_i2i64,
1119    { &replace31.value },
1120    NULL,
1121 };
1122 
1123    /* search33_0 -> search4_0 in the cache */
1124 static const nir_search_expression search33 = {
1125    { nir_search_value_expression, 64 },
1126    false, false,
1127    -1, 0,
1128    nir_op_i2i64,
1129    { &search4_0.value },
1130    NULL,
1131 };
1132 
1133    /* replace33_0_0 -> search4_0 in the cache */
1134 static const nir_search_expression replace33_0 = {
1135    { nir_search_value_expression, 32 },
1136    false, false,
1137    -1, 0,
1138    nir_op_i2i32,
1139    { &search4_0.value },
1140    NULL,
1141 };
1142 static const nir_search_expression replace33 = {
1143    { nir_search_value_expression, 64 },
1144    false, false,
1145    -1, 0,
1146    nir_op_i2i64,
1147    { &replace33_0.value },
1148    NULL,
1149 };
1150 
1151    /* search34_0 -> search23_0 in the cache */
1152 static const nir_search_expression search34 = {
1153    { nir_search_value_expression, 16 },
1154    false, false,
1155    -1, 0,
1156    nir_op_f2f16,
1157    { &search23_0.value },
1158    NULL,
1159 };
1160 
1161    /* replace34_0_0 -> search23_0 in the cache */
1162 static const nir_search_expression replace34_0 = {
1163    { nir_search_value_expression, 32 },
1164    false, false,
1165    -1, 0,
1166    nir_op_f2f32,
1167    { &search23_0.value },
1168    NULL,
1169 };
1170 static const nir_search_expression replace34 = {
1171    { nir_search_value_expression, 16 },
1172    false, false,
1173    -1, 0,
1174    nir_op_f2f16,
1175    { &replace34_0.value },
1176    NULL,
1177 };
1178 
1179    /* search35_0 -> search4_0 in the cache */
1180 static const nir_search_expression search35 = {
1181    { nir_search_value_expression, 64 },
1182    false, false,
1183    -1, 0,
1184    nir_op_f2f64,
1185    { &search4_0.value },
1186    NULL,
1187 };
1188 
1189    /* replace35_0_0 -> search4_0 in the cache */
1190 static const nir_search_expression replace35_0 = {
1191    { nir_search_value_expression, 32 },
1192    false, false,
1193    -1, 0,
1194    nir_op_f2f32,
1195    { &search4_0.value },
1196    NULL,
1197 };
1198 static const nir_search_expression replace35 = {
1199    { nir_search_value_expression, 64 },
1200    false, false,
1201    -1, 0,
1202    nir_op_f2f64,
1203    { &replace35_0.value },
1204    NULL,
1205 };
1206 
1207    /* search36_0 -> search1_0 in the cache */
1208 static const nir_search_expression search36 = {
1209    { nir_search_value_expression, 16 },
1210    false, false,
1211    -1, 0,
1212    nir_op_i2f16,
1213    { &search1_0.value },
1214    NULL,
1215 };
1216 
1217    /* replace36_0_0 -> search1_0 in the cache */
1218 /* replace36_0 -> replace31_0 in the cache */
1219 static const nir_search_expression replace36 = {
1220    { nir_search_value_expression, 16 },
1221    false, false,
1222    -1, 0,
1223    nir_op_i2f16,
1224    { &replace31_0.value },
1225    NULL,
1226 };
1227 
1228    /* search37_0 -> search7_0 in the cache */
1229 static const nir_search_expression search37 = {
1230    { nir_search_value_expression, 16 },
1231    false, false,
1232    -1, 0,
1233    nir_op_i2f16,
1234    { &search7_0.value },
1235    NULL,
1236 };
1237 
1238    /* replace37_0_0 -> search7_0 in the cache */
1239 static const nir_search_expression replace37_0 = {
1240    { nir_search_value_expression, 32 },
1241    false, false,
1242    -1, 0,
1243    nir_op_i2f32,
1244    { &search7_0.value },
1245    NULL,
1246 };
1247 static const nir_search_expression replace37 = {
1248    { nir_search_value_expression, 16 },
1249    false, false,
1250    -1, 0,
1251    nir_op_f2f16,
1252    { &replace37_0.value },
1253    NULL,
1254 };
1255 
1256    /* search38_0 -> search23_0 in the cache */
1257 static const nir_search_expression search38 = {
1258    { nir_search_value_expression, 16 },
1259    false, false,
1260    -1, 0,
1261    nir_op_i2f16,
1262    { &search23_0.value },
1263    NULL,
1264 };
1265 
1266    /* replace38_0_0_0 -> search23_0 in the cache */
1267 static const nir_search_expression replace38_0_0 = {
1268    { nir_search_value_expression, 64 },
1269    false, false,
1270    -1, 0,
1271    nir_op_i2f64,
1272    { &search23_0.value },
1273    NULL,
1274 };
1275 static const nir_search_expression replace38_0 = {
1276    { nir_search_value_expression, 32 },
1277    false, false,
1278    -1, 0,
1279    nir_op_f2f32,
1280    { &replace38_0_0.value },
1281    NULL,
1282 };
1283 static const nir_search_expression replace38 = {
1284    { nir_search_value_expression, 16 },
1285    false, false,
1286    -1, 0,
1287    nir_op_f2f16,
1288    { &replace38_0.value },
1289    NULL,
1290 };
1291 
1292    /* search39_0 -> search1_0 in the cache */
1293 static const nir_search_expression search39 = {
1294    { nir_search_value_expression, 32 },
1295    false, false,
1296    -1, 0,
1297    nir_op_i2f32,
1298    { &search1_0.value },
1299    NULL,
1300 };
1301 
1302    /* replace39_0_0_0 -> search1_0 in the cache */
1303 /* replace39_0_0 -> replace31_0 in the cache */
1304 /* replace39_0 -> replace31 in the cache */
1305 static const nir_search_expression replace39 = {
1306    { nir_search_value_expression, 32 },
1307    false, false,
1308    -1, 0,
1309    nir_op_i2f32,
1310    { &replace31.value },
1311    NULL,
1312 };
1313 
1314    /* search40_0 -> search4_0 in the cache */
1315 static const nir_search_expression search40 = {
1316    { nir_search_value_expression, 32 },
1317    false, false,
1318    -1, 0,
1319    nir_op_i2f32,
1320    { &search4_0.value },
1321    NULL,
1322 };
1323 
1324    /* replace40_0_0 -> search4_0 in the cache */
1325 /* replace40_0 -> replace33_0 in the cache */
1326 static const nir_search_expression replace40 = {
1327    { nir_search_value_expression, 32 },
1328    false, false,
1329    -1, 0,
1330    nir_op_i2f32,
1331    { &replace33_0.value },
1332    NULL,
1333 };
1334 
1335    /* search41_0 -> search23_0 in the cache */
1336 static const nir_search_expression search41 = {
1337    { nir_search_value_expression, 32 },
1338    false, false,
1339    -1, 0,
1340    nir_op_i2f32,
1341    { &search23_0.value },
1342    NULL,
1343 };
1344 
1345    /* replace41_0_0 -> search23_0 in the cache */
1346 /* replace41_0 -> replace38_0_0 in the cache */
1347 /* replace41 -> replace38_0 in the cache */
1348 
1349    /* search42_0 -> search1_0 in the cache */
1350 static const nir_search_expression search42 = {
1351    { nir_search_value_expression, 64 },
1352    false, false,
1353    -1, 0,
1354    nir_op_i2f64,
1355    { &search1_0.value },
1356    NULL,
1357 };
1358 
1359    /* replace42_0_0_0_0 -> search1_0 in the cache */
1360 /* replace42_0_0_0 -> replace31_0 in the cache */
1361 /* replace42_0_0 -> replace31 in the cache */
1362 /* replace42_0 -> replace32 in the cache */
1363 static const nir_search_expression replace42 = {
1364    { nir_search_value_expression, 64 },
1365    false, false,
1366    -1, 0,
1367    nir_op_i2f64,
1368    { &replace32.value },
1369    NULL,
1370 };
1371 
1372    /* search43_0 -> search4_0 in the cache */
1373 static const nir_search_expression search43 = {
1374    { nir_search_value_expression, 64 },
1375    false, false,
1376    -1, 0,
1377    nir_op_i2f64,
1378    { &search4_0.value },
1379    NULL,
1380 };
1381 
1382    /* replace43_0_0_0 -> search4_0 in the cache */
1383 /* replace43_0_0 -> replace33_0 in the cache */
1384 /* replace43_0 -> replace33 in the cache */
1385 static const nir_search_expression replace43 = {
1386    { nir_search_value_expression, 64 },
1387    false, false,
1388    -1, 0,
1389    nir_op_i2f64,
1390    { &replace33.value },
1391    NULL,
1392 };
1393 
1394    /* search44_0 -> search7_0 in the cache */
1395 static const nir_search_expression search44 = {
1396    { nir_search_value_expression, 64 },
1397    false, false,
1398    -1, 0,
1399    nir_op_i2f64,
1400    { &search7_0.value },
1401    NULL,
1402 };
1403 
1404    /* replace44_0_0 -> search7_0 in the cache */
1405 static const nir_search_expression replace44_0 = {
1406    { nir_search_value_expression, 64 },
1407    false, false,
1408    -1, 0,
1409    nir_op_i2i64,
1410    { &search7_0.value },
1411    NULL,
1412 };
1413 static const nir_search_expression replace44 = {
1414    { nir_search_value_expression, 64 },
1415    false, false,
1416    -1, 0,
1417    nir_op_i2f64,
1418    { &replace44_0.value },
1419    NULL,
1420 };
1421 
1422    /* search45_0 -> search1_0 in the cache */
1423 static const nir_search_expression search45 = {
1424    { nir_search_value_expression, 16 },
1425    false, false,
1426    -1, 0,
1427    nir_op_u2f16,
1428    { &search1_0.value },
1429    NULL,
1430 };
1431 
1432    /* replace45_0_0 -> search1_0 in the cache */
1433 /* replace45_0 -> replace25_0 in the cache */
1434 static const nir_search_expression replace45 = {
1435    { nir_search_value_expression, 16 },
1436    false, false,
1437    -1, 0,
1438    nir_op_u2f16,
1439    { &replace25_0.value },
1440    NULL,
1441 };
1442 
1443    /* search46_0 -> search7_0 in the cache */
1444 static const nir_search_expression search46 = {
1445    { nir_search_value_expression, 16 },
1446    false, false,
1447    -1, 0,
1448    nir_op_u2f16,
1449    { &search7_0.value },
1450    NULL,
1451 };
1452 
1453    /* replace46_0_0 -> search7_0 in the cache */
1454 static const nir_search_expression replace46_0 = {
1455    { nir_search_value_expression, 32 },
1456    false, false,
1457    -1, 0,
1458    nir_op_u2f32,
1459    { &search7_0.value },
1460    NULL,
1461 };
1462 static const nir_search_expression replace46 = {
1463    { nir_search_value_expression, 16 },
1464    false, false,
1465    -1, 0,
1466    nir_op_f2f16,
1467    { &replace46_0.value },
1468    NULL,
1469 };
1470 
1471    /* search47_0 -> search23_0 in the cache */
1472 static const nir_search_expression search47 = {
1473    { nir_search_value_expression, 16 },
1474    false, false,
1475    -1, 0,
1476    nir_op_u2f16,
1477    { &search23_0.value },
1478    NULL,
1479 };
1480 
1481    /* replace47_0_0_0 -> search23_0 in the cache */
1482 static const nir_search_expression replace47_0_0 = {
1483    { nir_search_value_expression, 64 },
1484    false, false,
1485    -1, 0,
1486    nir_op_u2f64,
1487    { &search23_0.value },
1488    NULL,
1489 };
1490 static const nir_search_expression replace47_0 = {
1491    { nir_search_value_expression, 32 },
1492    false, false,
1493    -1, 0,
1494    nir_op_f2f32,
1495    { &replace47_0_0.value },
1496    NULL,
1497 };
1498 static const nir_search_expression replace47 = {
1499    { nir_search_value_expression, 16 },
1500    false, false,
1501    -1, 0,
1502    nir_op_f2f16,
1503    { &replace47_0.value },
1504    NULL,
1505 };
1506 
1507    /* search48_0 -> search1_0 in the cache */
1508 static const nir_search_expression search48 = {
1509    { nir_search_value_expression, 32 },
1510    false, false,
1511    -1, 0,
1512    nir_op_u2f32,
1513    { &search1_0.value },
1514    NULL,
1515 };
1516 
1517    /* replace48_0_0_0 -> search1_0 in the cache */
1518 /* replace48_0_0 -> replace25_0 in the cache */
1519 /* replace48_0 -> replace25 in the cache */
1520 static const nir_search_expression replace48 = {
1521    { nir_search_value_expression, 32 },
1522    false, false,
1523    -1, 0,
1524    nir_op_u2f32,
1525    { &replace25.value },
1526    NULL,
1527 };
1528 
1529    /* search49_0 -> search4_0 in the cache */
1530 static const nir_search_expression search49 = {
1531    { nir_search_value_expression, 32 },
1532    false, false,
1533    -1, 0,
1534    nir_op_u2f32,
1535    { &search4_0.value },
1536    NULL,
1537 };
1538 
1539    /* replace49_0_0 -> search4_0 in the cache */
1540 /* replace49_0 -> replace27_0 in the cache */
1541 static const nir_search_expression replace49 = {
1542    { nir_search_value_expression, 32 },
1543    false, false,
1544    -1, 0,
1545    nir_op_u2f32,
1546    { &replace27_0.value },
1547    NULL,
1548 };
1549 
1550    /* search50_0 -> search23_0 in the cache */
1551 static const nir_search_expression search50 = {
1552    { nir_search_value_expression, 32 },
1553    false, false,
1554    -1, 0,
1555    nir_op_u2f32,
1556    { &search23_0.value },
1557    NULL,
1558 };
1559 
1560    /* replace50_0_0 -> search23_0 in the cache */
1561 /* replace50_0 -> replace47_0_0 in the cache */
1562 /* replace50 -> replace47_0 in the cache */
1563 
1564    /* search51_0 -> search1_0 in the cache */
1565 static const nir_search_expression search51 = {
1566    { nir_search_value_expression, 64 },
1567    false, false,
1568    -1, 0,
1569    nir_op_u2f64,
1570    { &search1_0.value },
1571    NULL,
1572 };
1573 
1574    /* replace51_0_0_0_0 -> search1_0 in the cache */
1575 /* replace51_0_0_0 -> replace25_0 in the cache */
1576 /* replace51_0_0 -> replace25 in the cache */
1577 /* replace51_0 -> replace26 in the cache */
1578 static const nir_search_expression replace51 = {
1579    { nir_search_value_expression, 64 },
1580    false, false,
1581    -1, 0,
1582    nir_op_u2f64,
1583    { &replace26.value },
1584    NULL,
1585 };
1586 
1587    /* search52_0 -> search4_0 in the cache */
1588 static const nir_search_expression search52 = {
1589    { nir_search_value_expression, 64 },
1590    false, false,
1591    -1, 0,
1592    nir_op_u2f64,
1593    { &search4_0.value },
1594    NULL,
1595 };
1596 
1597    /* replace52_0_0_0 -> search4_0 in the cache */
1598 /* replace52_0_0 -> replace27_0 in the cache */
1599 /* replace52_0 -> replace27 in the cache */
1600 static const nir_search_expression replace52 = {
1601    { nir_search_value_expression, 64 },
1602    false, false,
1603    -1, 0,
1604    nir_op_u2f64,
1605    { &replace27.value },
1606    NULL,
1607 };
1608 
1609    /* search53_0 -> search7_0 in the cache */
1610 static const nir_search_expression search53 = {
1611    { nir_search_value_expression, 64 },
1612    false, false,
1613    -1, 0,
1614    nir_op_u2f64,
1615    { &search7_0.value },
1616    NULL,
1617 };
1618 
1619    /* replace53_0_0 -> search7_0 in the cache */
1620 static const nir_search_expression replace53_0 = {
1621    { nir_search_value_expression, 64 },
1622    false, false,
1623    -1, 0,
1624    nir_op_u2u64,
1625    { &search7_0.value },
1626    NULL,
1627 };
1628 static const nir_search_expression replace53 = {
1629    { nir_search_value_expression, 64 },
1630    false, false,
1631    -1, 0,
1632    nir_op_u2f64,
1633    { &replace53_0.value },
1634    NULL,
1635 };
1636 
1637    /* search54_0 -> search4_0 in the cache */
1638 static const nir_search_expression search54 = {
1639    { nir_search_value_expression, 8 },
1640    false, false,
1641    -1, 0,
1642    nir_op_f2i8,
1643    { &search4_0.value },
1644    NULL,
1645 };
1646 
1647    /* replace54_0_0 -> search4_0 in the cache */
1648 static const nir_search_expression replace54_0 = {
1649    { nir_search_value_expression, 16 },
1650    false, false,
1651    -1, 0,
1652    nir_op_f2i16,
1653    { &search4_0.value },
1654    NULL,
1655 };
1656 static const nir_search_expression replace54 = {
1657    { nir_search_value_expression, 8 },
1658    false, false,
1659    -1, 0,
1660    nir_op_i2i8,
1661    { &replace54_0.value },
1662    NULL,
1663 };
1664 
1665    /* search55_0 -> search7_0 in the cache */
1666 static const nir_search_expression search55 = {
1667    { nir_search_value_expression, 8 },
1668    false, false,
1669    -1, 0,
1670    nir_op_f2i8,
1671    { &search7_0.value },
1672    NULL,
1673 };
1674 
1675    /* replace55_0_0_0 -> search7_0 in the cache */
1676 static const nir_search_expression replace55_0_0 = {
1677    { nir_search_value_expression, 32 },
1678    false, false,
1679    -1, 0,
1680    nir_op_f2i32,
1681    { &search7_0.value },
1682    NULL,
1683 };
1684 static const nir_search_expression replace55_0 = {
1685    { nir_search_value_expression, 16 },
1686    false, false,
1687    -1, 0,
1688    nir_op_i2i16,
1689    { &replace55_0_0.value },
1690    NULL,
1691 };
1692 static const nir_search_expression replace55 = {
1693    { nir_search_value_expression, 8 },
1694    false, false,
1695    -1, 0,
1696    nir_op_i2i8,
1697    { &replace55_0.value },
1698    NULL,
1699 };
1700 
1701    /* search56_0 -> search23_0 in the cache */
1702 static const nir_search_expression search56 = {
1703    { nir_search_value_expression, 8 },
1704    false, false,
1705    -1, 0,
1706    nir_op_f2i8,
1707    { &search23_0.value },
1708    NULL,
1709 };
1710 
1711    /* replace56_0_0_0_0 -> search23_0 in the cache */
1712 static const nir_search_expression replace56_0_0_0 = {
1713    { nir_search_value_expression, 64 },
1714    false, false,
1715    -1, 0,
1716    nir_op_f2i64,
1717    { &search23_0.value },
1718    NULL,
1719 };
1720 static const nir_search_expression replace56_0_0 = {
1721    { nir_search_value_expression, 32 },
1722    false, false,
1723    -1, 0,
1724    nir_op_i2i32,
1725    { &replace56_0_0_0.value },
1726    NULL,
1727 };
1728 static const nir_search_expression replace56_0 = {
1729    { nir_search_value_expression, 16 },
1730    false, false,
1731    -1, 0,
1732    nir_op_i2i16,
1733    { &replace56_0_0.value },
1734    NULL,
1735 };
1736 static const nir_search_expression replace56 = {
1737    { nir_search_value_expression, 8 },
1738    false, false,
1739    -1, 0,
1740    nir_op_i2i8,
1741    { &replace56_0.value },
1742    NULL,
1743 };
1744 
1745    /* search57_0 -> search7_0 in the cache */
1746 static const nir_search_expression search57 = {
1747    { nir_search_value_expression, 16 },
1748    false, false,
1749    -1, 0,
1750    nir_op_f2i16,
1751    { &search7_0.value },
1752    NULL,
1753 };
1754 
1755    /* replace57_0_0 -> search7_0 in the cache */
1756 /* replace57_0 -> replace55_0_0 in the cache */
1757 /* replace57 -> replace55_0 in the cache */
1758 
1759    /* search58_0 -> search23_0 in the cache */
1760 static const nir_search_expression search58 = {
1761    { nir_search_value_expression, 16 },
1762    false, false,
1763    -1, 0,
1764    nir_op_f2i16,
1765    { &search23_0.value },
1766    NULL,
1767 };
1768 
1769    /* replace58_0_0_0 -> search23_0 in the cache */
1770 /* replace58_0_0 -> replace56_0_0_0 in the cache */
1771 /* replace58_0 -> replace56_0_0 in the cache */
1772 /* replace58 -> replace56_0 in the cache */
1773 
1774    /* search59_0 -> search4_0 in the cache */
1775 static const nir_search_expression search59 = {
1776    { nir_search_value_expression, 32 },
1777    false, false,
1778    -1, 0,
1779    nir_op_f2i32,
1780    { &search4_0.value },
1781    NULL,
1782 };
1783 
1784    /* replace59_0_0 -> search4_0 in the cache */
1785 /* replace59_0 -> replace35_0 in the cache */
1786 static const nir_search_expression replace59 = {
1787    { nir_search_value_expression, 32 },
1788    false, false,
1789    -1, 0,
1790    nir_op_f2i32,
1791    { &replace35_0.value },
1792    NULL,
1793 };
1794 
1795    /* search60_0 -> search23_0 in the cache */
1796 static const nir_search_expression search60 = {
1797    { nir_search_value_expression, 32 },
1798    false, false,
1799    -1, 0,
1800    nir_op_f2i32,
1801    { &search23_0.value },
1802    NULL,
1803 };
1804 
1805    /* replace60_0_0 -> search23_0 in the cache */
1806 /* replace60_0 -> replace56_0_0_0 in the cache */
1807 /* replace60 -> replace56_0_0 in the cache */
1808 
1809    /* search61_0 -> search4_0 in the cache */
1810 static const nir_search_expression search61 = {
1811    { nir_search_value_expression, 64 },
1812    false, false,
1813    -1, 0,
1814    nir_op_f2i64,
1815    { &search4_0.value },
1816    NULL,
1817 };
1818 
1819    /* replace61_0_0_0 -> search4_0 in the cache */
1820 /* replace61_0_0 -> replace35_0 in the cache */
1821 /* replace61_0 -> replace35 in the cache */
1822 static const nir_search_expression replace61 = {
1823    { nir_search_value_expression, 64 },
1824    false, false,
1825    -1, 0,
1826    nir_op_f2i64,
1827    { &replace35.value },
1828    NULL,
1829 };
1830 
1831    /* search62_0 -> search7_0 in the cache */
1832 static const nir_search_expression search62 = {
1833    { nir_search_value_expression, 64 },
1834    false, false,
1835    -1, 0,
1836    nir_op_f2i64,
1837    { &search7_0.value },
1838    NULL,
1839 };
1840 
1841    /* replace62_0_0 -> search7_0 in the cache */
1842 static const nir_search_expression replace62_0 = {
1843    { nir_search_value_expression, 64 },
1844    false, false,
1845    -1, 0,
1846    nir_op_f2f64,
1847    { &search7_0.value },
1848    NULL,
1849 };
1850 static const nir_search_expression replace62 = {
1851    { nir_search_value_expression, 64 },
1852    false, false,
1853    -1, 0,
1854    nir_op_f2i64,
1855    { &replace62_0.value },
1856    NULL,
1857 };
1858 
1859    /* search63_0 -> search4_0 in the cache */
1860 static const nir_search_expression search63 = {
1861    { nir_search_value_expression, 8 },
1862    false, false,
1863    -1, 0,
1864    nir_op_f2u8,
1865    { &search4_0.value },
1866    NULL,
1867 };
1868 
1869    /* replace63_0_0 -> search4_0 in the cache */
1870 static const nir_search_expression replace63_0 = {
1871    { nir_search_value_expression, 16 },
1872    false, false,
1873    -1, 0,
1874    nir_op_f2u16,
1875    { &search4_0.value },
1876    NULL,
1877 };
1878 static const nir_search_expression replace63 = {
1879    { nir_search_value_expression, 8 },
1880    false, false,
1881    -1, 0,
1882    nir_op_u2u8,
1883    { &replace63_0.value },
1884    NULL,
1885 };
1886 
1887    /* search64_0 -> search7_0 in the cache */
1888 static const nir_search_expression search64 = {
1889    { nir_search_value_expression, 8 },
1890    false, false,
1891    -1, 0,
1892    nir_op_f2u8,
1893    { &search7_0.value },
1894    NULL,
1895 };
1896 
1897    /* replace64_0_0_0 -> search7_0 in the cache */
1898 static const nir_search_expression replace64_0_0 = {
1899    { nir_search_value_expression, 32 },
1900    false, false,
1901    -1, 0,
1902    nir_op_f2u32,
1903    { &search7_0.value },
1904    NULL,
1905 };
1906 static const nir_search_expression replace64_0 = {
1907    { nir_search_value_expression, 16 },
1908    false, false,
1909    -1, 0,
1910    nir_op_u2u16,
1911    { &replace64_0_0.value },
1912    NULL,
1913 };
1914 static const nir_search_expression replace64 = {
1915    { nir_search_value_expression, 8 },
1916    false, false,
1917    -1, 0,
1918    nir_op_u2u8,
1919    { &replace64_0.value },
1920    NULL,
1921 };
1922 
1923    /* search65_0 -> search23_0 in the cache */
1924 static const nir_search_expression search65 = {
1925    { nir_search_value_expression, 8 },
1926    false, false,
1927    -1, 0,
1928    nir_op_f2u8,
1929    { &search23_0.value },
1930    NULL,
1931 };
1932 
1933    /* replace65_0_0_0_0 -> search23_0 in the cache */
1934 static const nir_search_expression replace65_0_0_0 = {
1935    { nir_search_value_expression, 64 },
1936    false, false,
1937    -1, 0,
1938    nir_op_f2u64,
1939    { &search23_0.value },
1940    NULL,
1941 };
1942 static const nir_search_expression replace65_0_0 = {
1943    { nir_search_value_expression, 32 },
1944    false, false,
1945    -1, 0,
1946    nir_op_u2u32,
1947    { &replace65_0_0_0.value },
1948    NULL,
1949 };
1950 static const nir_search_expression replace65_0 = {
1951    { nir_search_value_expression, 16 },
1952    false, false,
1953    -1, 0,
1954    nir_op_u2u16,
1955    { &replace65_0_0.value },
1956    NULL,
1957 };
1958 static const nir_search_expression replace65 = {
1959    { nir_search_value_expression, 8 },
1960    false, false,
1961    -1, 0,
1962    nir_op_u2u8,
1963    { &replace65_0.value },
1964    NULL,
1965 };
1966 
1967    /* search66_0 -> search7_0 in the cache */
1968 static const nir_search_expression search66 = {
1969    { nir_search_value_expression, 16 },
1970    false, false,
1971    -1, 0,
1972    nir_op_f2u16,
1973    { &search7_0.value },
1974    NULL,
1975 };
1976 
1977    /* replace66_0_0 -> search7_0 in the cache */
1978 /* replace66_0 -> replace64_0_0 in the cache */
1979 /* replace66 -> replace64_0 in the cache */
1980 
1981    /* search67_0 -> search23_0 in the cache */
1982 static const nir_search_expression search67 = {
1983    { nir_search_value_expression, 16 },
1984    false, false,
1985    -1, 0,
1986    nir_op_f2u16,
1987    { &search23_0.value },
1988    NULL,
1989 };
1990 
1991    /* replace67_0_0_0 -> search23_0 in the cache */
1992 /* replace67_0_0 -> replace65_0_0_0 in the cache */
1993 /* replace67_0 -> replace65_0_0 in the cache */
1994 /* replace67 -> replace65_0 in the cache */
1995 
1996    /* search68_0 -> search4_0 in the cache */
1997 static const nir_search_expression search68 = {
1998    { nir_search_value_expression, 32 },
1999    false, false,
2000    -1, 0,
2001    nir_op_f2u32,
2002    { &search4_0.value },
2003    NULL,
2004 };
2005 
2006    /* replace68_0_0 -> search4_0 in the cache */
2007 /* replace68_0 -> replace35_0 in the cache */
2008 static const nir_search_expression replace68 = {
2009    { nir_search_value_expression, 32 },
2010    false, false,
2011    -1, 0,
2012    nir_op_f2u32,
2013    { &replace35_0.value },
2014    NULL,
2015 };
2016 
2017    /* search69_0 -> search23_0 in the cache */
2018 static const nir_search_expression search69 = {
2019    { nir_search_value_expression, 32 },
2020    false, false,
2021    -1, 0,
2022    nir_op_f2u32,
2023    { &search23_0.value },
2024    NULL,
2025 };
2026 
2027    /* replace69_0_0 -> search23_0 in the cache */
2028 /* replace69_0 -> replace65_0_0_0 in the cache */
2029 /* replace69 -> replace65_0_0 in the cache */
2030 
2031    /* search70_0 -> search4_0 in the cache */
2032 static const nir_search_expression search70 = {
2033    { nir_search_value_expression, 64 },
2034    false, false,
2035    -1, 0,
2036    nir_op_f2u64,
2037    { &search4_0.value },
2038    NULL,
2039 };
2040 
2041    /* replace70_0_0_0 -> search4_0 in the cache */
2042 /* replace70_0_0 -> replace35_0 in the cache */
2043 /* replace70_0 -> replace35 in the cache */
2044 static const nir_search_expression replace70 = {
2045    { nir_search_value_expression, 64 },
2046    false, false,
2047    -1, 0,
2048    nir_op_f2u64,
2049    { &replace35.value },
2050    NULL,
2051 };
2052 
2053    /* search71_0 -> search7_0 in the cache */
2054 static const nir_search_expression search71 = {
2055    { nir_search_value_expression, 64 },
2056    false, false,
2057    -1, 0,
2058    nir_op_f2u64,
2059    { &search7_0.value },
2060    NULL,
2061 };
2062 
2063    /* replace71_0_0 -> search7_0 in the cache */
2064 /* replace71_0 -> replace62_0 in the cache */
2065 static const nir_search_expression replace71 = {
2066    { nir_search_value_expression, 64 },
2067    false, false,
2068    -1, 0,
2069    nir_op_f2u64,
2070    { &replace62_0.value },
2071    NULL,
2072 };
2073 
2074    /* search72_0 -> search4_0 in the cache */
2075 static const nir_search_expression search72 = {
2076    { nir_search_value_expression, 16 },
2077    false, false,
2078    -1, 0,
2079    nir_op_fexp2,
2080    { &search4_0.value },
2081    NULL,
2082 };
2083 
2084    /* replace72_0_0_0 -> search4_0 in the cache */
2085 /* replace72_0_0 -> replace35_0 in the cache */
2086 static const nir_search_expression replace72_0 = {
2087    { nir_search_value_expression, 32 },
2088    false, false,
2089    -1, 0,
2090    nir_op_fexp2,
2091    { &replace35_0.value },
2092    NULL,
2093 };
2094 static const nir_search_expression replace72 = {
2095    { nir_search_value_expression, 16 },
2096    false, false,
2097    -1, 0,
2098    nir_op_f2f16,
2099    { &replace72_0.value },
2100    NULL,
2101 };
2102 
2103    /* search73_0 -> search4_0 in the cache */
2104 static const nir_search_expression search73 = {
2105    { nir_search_value_expression, 16 },
2106    false, false,
2107    -1, 0,
2108    nir_op_flog2,
2109    { &search4_0.value },
2110    NULL,
2111 };
2112 
2113    /* replace73_0_0_0 -> search4_0 in the cache */
2114 /* replace73_0_0 -> replace35_0 in the cache */
2115 static const nir_search_expression replace73_0 = {
2116    { nir_search_value_expression, 32 },
2117    false, false,
2118    -1, 0,
2119    nir_op_flog2,
2120    { &replace35_0.value },
2121    NULL,
2122 };
2123 static const nir_search_expression replace73 = {
2124    { nir_search_value_expression, 16 },
2125    false, false,
2126    -1, 0,
2127    nir_op_f2f16,
2128    { &replace73_0.value },
2129    NULL,
2130 };
2131 
2132    /* search74_0 -> search4_0 in the cache */
2133 static const nir_search_expression search74 = {
2134    { nir_search_value_expression, 16 },
2135    false, false,
2136    -1, 0,
2137    nir_op_fsin,
2138    { &search4_0.value },
2139    NULL,
2140 };
2141 
2142    /* replace74_0_0_0 -> search4_0 in the cache */
2143 /* replace74_0_0 -> replace35_0 in the cache */
2144 static const nir_search_expression replace74_0 = {
2145    { nir_search_value_expression, 32 },
2146    false, false,
2147    -1, 0,
2148    nir_op_fsin,
2149    { &replace35_0.value },
2150    NULL,
2151 };
2152 static const nir_search_expression replace74 = {
2153    { nir_search_value_expression, 16 },
2154    false, false,
2155    -1, 0,
2156    nir_op_f2f16,
2157    { &replace74_0.value },
2158    NULL,
2159 };
2160 
2161    /* search75_0 -> search4_0 in the cache */
2162 static const nir_search_expression search75 = {
2163    { nir_search_value_expression, 16 },
2164    false, false,
2165    -1, 0,
2166    nir_op_fcos,
2167    { &search4_0.value },
2168    NULL,
2169 };
2170 
2171    /* replace75_0_0_0 -> search4_0 in the cache */
2172 /* replace75_0_0 -> replace35_0 in the cache */
2173 static const nir_search_expression replace75_0 = {
2174    { nir_search_value_expression, 32 },
2175    false, false,
2176    -1, 0,
2177    nir_op_fcos,
2178    { &replace35_0.value },
2179    NULL,
2180 };
2181 static const nir_search_expression replace75 = {
2182    { nir_search_value_expression, 16 },
2183    false, false,
2184    -1, 0,
2185    nir_op_f2f16,
2186    { &replace75_0.value },
2187    NULL,
2188 };
2189 
2190    /* search76_0 -> search0_0 in the cache */
2191 static const nir_search_expression search76 = {
2192    { nir_search_value_expression, 32 },
2193    false, false,
2194    -1, 0,
2195    nir_op_f2b32,
2196    { &search0_0.value },
2197    NULL,
2198 };
2199 
2200    /* replace76_0 -> search0_0 in the cache */
2201 
2202 static const nir_search_constant replace76_1 = {
2203    { nir_search_value_constant, -1 },
2204    nir_type_float, { 0x0 /* 0.0 */ },
2205 };
2206 static const nir_search_expression replace76 = {
2207    { nir_search_value_expression, 32 },
2208    false, false,
2209    0, 1,
2210    nir_op_fneu32,
2211    { &search0_0.value, &replace76_1.value },
2212    NULL,
2213 };
2214 
2215    /* search77_0 -> search0_0 in the cache */
2216 static const nir_search_expression search77 = {
2217    { nir_search_value_expression, 32 },
2218    false, false,
2219    -1, 0,
2220    nir_op_i2b32,
2221    { &search0_0.value },
2222    NULL,
2223 };
2224 
2225    /* replace77_0 -> search0_0 in the cache */
2226 
2227 /* replace77_1 -> replace0_0 in the cache */
2228 static const nir_search_expression replace77 = {
2229    { nir_search_value_expression, 32 },
2230    false, false,
2231    0, 1,
2232    nir_op_ine32,
2233    { &search0_0.value, &replace0_0.value },
2234    NULL,
2235 };
2236 
2237    /* search78_0 -> search7_0 in the cache */
2238 static const nir_search_expression search78 = {
2239    { nir_search_value_expression, 32 },
2240    false, false,
2241    -1, 0,
2242    nir_op_b2i32,
2243    { &search7_0.value },
2244    NULL,
2245 };
2246 
2247    /* replace78_0 -> search7_0 in the cache */
2248 
2249 static const nir_search_constant replace78_1 = {
2250    { nir_search_value_constant, 32 },
2251    nir_type_int, { 0x1 /* 1 */ },
2252 };
2253 static const nir_search_expression replace78 = {
2254    { nir_search_value_expression, 32 },
2255    false, false,
2256    0, 1,
2257    nir_op_iand,
2258    { &search7_0.value, &replace78_1.value },
2259    NULL,
2260 };
2261 
2262 
2263 static const struct transform bifrost_nir_lower_algebraic_late_state2_xforms[] = {
2264   { &search0, &replace0.value, 0 },
2265 };
2266 static const struct transform bifrost_nir_lower_algebraic_late_state3_xforms[] = {
2267   { &search1, &replace1.value, 0 },
2268   { &search2, &replace2.value, 0 },
2269   { &search3, &replace3.value, 0 },
2270   { &search4, &replace4.value, 0 },
2271   { &search5, &replace5.value, 0 },
2272   { &search6, &replace6.value, 0 },
2273   { &search7, &replace7.value, 0 },
2274   { &search8, &replace8.value, 0 },
2275   { &search9, &replace9.value, 0 },
2276 };
2277 static const struct transform bifrost_nir_lower_algebraic_late_state4_xforms[] = {
2278   { &search10, &replace10.value, 0 },
2279   { &search14, &replace14.value, 0 },
2280   { &search18, &replace18.value, 0 },
2281 };
2282 static const struct transform bifrost_nir_lower_algebraic_late_state5_xforms[] = {
2283   { &search11, &replace11.value, 0 },
2284   { &search15, &replace15.value, 0 },
2285   { &search19, &replace19.value, 0 },
2286 };
2287 static const struct transform bifrost_nir_lower_algebraic_late_state6_xforms[] = {
2288   { &search12, &replace12.value, 0 },
2289   { &search16, &replace16.value, 0 },
2290   { &search20, &replace20.value, 0 },
2291 };
2292 static const struct transform bifrost_nir_lower_algebraic_late_state7_xforms[] = {
2293   { &search13, &replace13.value, 0 },
2294   { &search17, &replace17.value, 0 },
2295   { &search21, &replace21.value, 0 },
2296 };
2297 static const struct transform bifrost_nir_lower_algebraic_late_state8_xforms[] = {
2298   { &search22, &replace22.value, 0 },
2299   { &search23, &replace23.value, 0 },
2300   { &search24, &replace23_0.value, 0 },
2301   { &search25, &replace25.value, 0 },
2302   { &search26, &replace26.value, 0 },
2303   { &search27, &replace27.value, 0 },
2304 };
2305 static const struct transform bifrost_nir_lower_algebraic_late_state9_xforms[] = {
2306   { &search28, &replace28.value, 0 },
2307   { &search29, &replace29.value, 0 },
2308   { &search30, &replace29_0.value, 0 },
2309   { &search31, &replace31.value, 0 },
2310   { &search32, &replace32.value, 0 },
2311   { &search33, &replace33.value, 0 },
2312 };
2313 static const struct transform bifrost_nir_lower_algebraic_late_state10_xforms[] = {
2314   { &search34, &replace34.value, 0 },
2315   { &search35, &replace35.value, 0 },
2316 };
2317 static const struct transform bifrost_nir_lower_algebraic_late_state11_xforms[] = {
2318   { &search36, &replace36.value, 0 },
2319   { &search37, &replace37.value, 0 },
2320   { &search38, &replace38.value, 0 },
2321   { &search39, &replace39.value, 0 },
2322   { &search40, &replace40.value, 0 },
2323   { &search41, &replace38_0.value, 0 },
2324   { &search42, &replace42.value, 0 },
2325   { &search43, &replace43.value, 0 },
2326   { &search44, &replace44.value, 0 },
2327 };
2328 static const struct transform bifrost_nir_lower_algebraic_late_state12_xforms[] = {
2329   { &search45, &replace45.value, 0 },
2330   { &search46, &replace46.value, 0 },
2331   { &search47, &replace47.value, 0 },
2332   { &search48, &replace48.value, 0 },
2333   { &search49, &replace49.value, 0 },
2334   { &search50, &replace47_0.value, 0 },
2335   { &search51, &replace51.value, 0 },
2336   { &search52, &replace52.value, 0 },
2337   { &search53, &replace53.value, 0 },
2338 };
2339 static const struct transform bifrost_nir_lower_algebraic_late_state13_xforms[] = {
2340   { &search54, &replace54.value, 0 },
2341   { &search55, &replace55.value, 0 },
2342   { &search56, &replace56.value, 0 },
2343   { &search57, &replace55_0.value, 0 },
2344   { &search58, &replace56_0.value, 0 },
2345   { &search59, &replace59.value, 0 },
2346   { &search60, &replace56_0_0.value, 0 },
2347   { &search61, &replace61.value, 0 },
2348   { &search62, &replace62.value, 0 },
2349 };
2350 static const struct transform bifrost_nir_lower_algebraic_late_state14_xforms[] = {
2351   { &search63, &replace63.value, 0 },
2352   { &search64, &replace64.value, 0 },
2353   { &search65, &replace65.value, 0 },
2354   { &search66, &replace64_0.value, 0 },
2355   { &search67, &replace65_0.value, 0 },
2356   { &search68, &replace68.value, 0 },
2357   { &search69, &replace65_0_0.value, 0 },
2358   { &search70, &replace70.value, 0 },
2359   { &search71, &replace71.value, 0 },
2360 };
2361 static const struct transform bifrost_nir_lower_algebraic_late_state15_xforms[] = {
2362   { &search72, &replace72.value, 0 },
2363 };
2364 static const struct transform bifrost_nir_lower_algebraic_late_state16_xforms[] = {
2365   { &search73, &replace73.value, 0 },
2366 };
2367 static const struct transform bifrost_nir_lower_algebraic_late_state17_xforms[] = {
2368   { &search74, &replace74.value, 0 },
2369 };
2370 static const struct transform bifrost_nir_lower_algebraic_late_state18_xforms[] = {
2371   { &search75, &replace75.value, 0 },
2372 };
2373 static const struct transform bifrost_nir_lower_algebraic_late_state19_xforms[] = {
2374   { &search76, &replace76.value, 0 },
2375 };
2376 static const struct transform bifrost_nir_lower_algebraic_late_state20_xforms[] = {
2377   { &search77, &replace77.value, 0 },
2378 };
2379 static const struct transform bifrost_nir_lower_algebraic_late_state21_xforms[] = {
2380   { &search78, &replace78.value, 0 },
2381 };
2382 
2383 static const struct per_op_table bifrost_nir_lower_algebraic_late_table[nir_num_search_ops] = {
2384    [nir_op_ineg] = {
2385       .filter = (uint16_t []) {
2386          0,
2387          0,
2388          0,
2389          0,
2390          0,
2391          0,
2392          0,
2393          0,
2394          0,
2395          0,
2396          0,
2397          0,
2398          0,
2399          0,
2400          0,
2401          0,
2402          0,
2403          0,
2404          0,
2405          0,
2406          0,
2407          0,
2408       },
2409 
2410       .num_filtered_states = 1,
2411       .table = (uint16_t []) {
2412 
2413          2,
2414       },
2415    },
2416    [nir_search_op_b2f] = {
2417       .filter = (uint16_t []) {
2418          0,
2419          0,
2420          0,
2421          0,
2422          0,
2423          0,
2424          0,
2425          0,
2426          0,
2427          0,
2428          0,
2429          0,
2430          0,
2431          0,
2432          0,
2433          0,
2434          0,
2435          0,
2436          0,
2437          0,
2438          0,
2439          0,
2440       },
2441 
2442       .num_filtered_states = 1,
2443       .table = (uint16_t []) {
2444 
2445          3,
2446       },
2447    },
2448    [nir_op_imin] = {
2449       .filter = (uint16_t []) {
2450          0,
2451          0,
2452          0,
2453          0,
2454          0,
2455          0,
2456          0,
2457          0,
2458          0,
2459          0,
2460          0,
2461          0,
2462          0,
2463          0,
2464          0,
2465          0,
2466          0,
2467          0,
2468          0,
2469          0,
2470          0,
2471          0,
2472       },
2473 
2474       .num_filtered_states = 1,
2475       .table = (uint16_t []) {
2476 
2477          4,
2478       },
2479    },
2480    [nir_op_imax] = {
2481       .filter = (uint16_t []) {
2482          0,
2483          0,
2484          0,
2485          0,
2486          0,
2487          0,
2488          0,
2489          0,
2490          0,
2491          0,
2492          0,
2493          0,
2494          0,
2495          0,
2496          0,
2497          0,
2498          0,
2499          0,
2500          0,
2501          0,
2502          0,
2503          0,
2504       },
2505 
2506       .num_filtered_states = 1,
2507       .table = (uint16_t []) {
2508 
2509          5,
2510       },
2511    },
2512    [nir_op_umin] = {
2513       .filter = (uint16_t []) {
2514          0,
2515          0,
2516          0,
2517          0,
2518          0,
2519          0,
2520          0,
2521          0,
2522          0,
2523          0,
2524          0,
2525          0,
2526          0,
2527          0,
2528          0,
2529          0,
2530          0,
2531          0,
2532          0,
2533          0,
2534          0,
2535          0,
2536       },
2537 
2538       .num_filtered_states = 1,
2539       .table = (uint16_t []) {
2540 
2541          6,
2542       },
2543    },
2544    [nir_op_umax] = {
2545       .filter = (uint16_t []) {
2546          0,
2547          0,
2548          0,
2549          0,
2550          0,
2551          0,
2552          0,
2553          0,
2554          0,
2555          0,
2556          0,
2557          0,
2558          0,
2559          0,
2560          0,
2561          0,
2562          0,
2563          0,
2564          0,
2565          0,
2566          0,
2567          0,
2568       },
2569 
2570       .num_filtered_states = 1,
2571       .table = (uint16_t []) {
2572 
2573          7,
2574       },
2575    },
2576    [nir_search_op_u2u] = {
2577       .filter = (uint16_t []) {
2578          0,
2579          0,
2580          0,
2581          0,
2582          0,
2583          0,
2584          0,
2585          0,
2586          0,
2587          0,
2588          0,
2589          0,
2590          0,
2591          0,
2592          0,
2593          0,
2594          0,
2595          0,
2596          0,
2597          0,
2598          0,
2599          0,
2600       },
2601 
2602       .num_filtered_states = 1,
2603       .table = (uint16_t []) {
2604 
2605          8,
2606       },
2607    },
2608    [nir_search_op_i2i] = {
2609       .filter = (uint16_t []) {
2610          0,
2611          0,
2612          0,
2613          0,
2614          0,
2615          0,
2616          0,
2617          0,
2618          0,
2619          0,
2620          0,
2621          0,
2622          0,
2623          0,
2624          0,
2625          0,
2626          0,
2627          0,
2628          0,
2629          0,
2630          0,
2631          0,
2632       },
2633 
2634       .num_filtered_states = 1,
2635       .table = (uint16_t []) {
2636 
2637          9,
2638       },
2639    },
2640    [nir_search_op_f2f] = {
2641       .filter = (uint16_t []) {
2642          0,
2643          0,
2644          0,
2645          0,
2646          0,
2647          0,
2648          0,
2649          0,
2650          0,
2651          0,
2652          0,
2653          0,
2654          0,
2655          0,
2656          0,
2657          0,
2658          0,
2659          0,
2660          0,
2661          0,
2662          0,
2663          0,
2664       },
2665 
2666       .num_filtered_states = 1,
2667       .table = (uint16_t []) {
2668 
2669          10,
2670       },
2671    },
2672    [nir_search_op_i2f] = {
2673       .filter = (uint16_t []) {
2674          0,
2675          0,
2676          0,
2677          0,
2678          0,
2679          0,
2680          0,
2681          0,
2682          0,
2683          0,
2684          0,
2685          0,
2686          0,
2687          0,
2688          0,
2689          0,
2690          0,
2691          0,
2692          0,
2693          0,
2694          0,
2695          0,
2696       },
2697 
2698       .num_filtered_states = 1,
2699       .table = (uint16_t []) {
2700 
2701          11,
2702       },
2703    },
2704    [nir_search_op_u2f] = {
2705       .filter = (uint16_t []) {
2706          0,
2707          0,
2708          0,
2709          0,
2710          0,
2711          0,
2712          0,
2713          0,
2714          0,
2715          0,
2716          0,
2717          0,
2718          0,
2719          0,
2720          0,
2721          0,
2722          0,
2723          0,
2724          0,
2725          0,
2726          0,
2727          0,
2728       },
2729 
2730       .num_filtered_states = 1,
2731       .table = (uint16_t []) {
2732 
2733          12,
2734       },
2735    },
2736    [nir_search_op_f2i] = {
2737       .filter = (uint16_t []) {
2738          0,
2739          0,
2740          0,
2741          0,
2742          0,
2743          0,
2744          0,
2745          0,
2746          0,
2747          0,
2748          0,
2749          0,
2750          0,
2751          0,
2752          0,
2753          0,
2754          0,
2755          0,
2756          0,
2757          0,
2758          0,
2759          0,
2760       },
2761 
2762       .num_filtered_states = 1,
2763       .table = (uint16_t []) {
2764 
2765          13,
2766       },
2767    },
2768    [nir_search_op_f2u] = {
2769       .filter = (uint16_t []) {
2770          0,
2771          0,
2772          0,
2773          0,
2774          0,
2775          0,
2776          0,
2777          0,
2778          0,
2779          0,
2780          0,
2781          0,
2782          0,
2783          0,
2784          0,
2785          0,
2786          0,
2787          0,
2788          0,
2789          0,
2790          0,
2791          0,
2792       },
2793 
2794       .num_filtered_states = 1,
2795       .table = (uint16_t []) {
2796 
2797          14,
2798       },
2799    },
2800    [nir_op_fexp2] = {
2801       .filter = (uint16_t []) {
2802          0,
2803          0,
2804          0,
2805          0,
2806          0,
2807          0,
2808          0,
2809          0,
2810          0,
2811          0,
2812          0,
2813          0,
2814          0,
2815          0,
2816          0,
2817          0,
2818          0,
2819          0,
2820          0,
2821          0,
2822          0,
2823          0,
2824       },
2825 
2826       .num_filtered_states = 1,
2827       .table = (uint16_t []) {
2828 
2829          15,
2830       },
2831    },
2832    [nir_op_flog2] = {
2833       .filter = (uint16_t []) {
2834          0,
2835          0,
2836          0,
2837          0,
2838          0,
2839          0,
2840          0,
2841          0,
2842          0,
2843          0,
2844          0,
2845          0,
2846          0,
2847          0,
2848          0,
2849          0,
2850          0,
2851          0,
2852          0,
2853          0,
2854          0,
2855          0,
2856       },
2857 
2858       .num_filtered_states = 1,
2859       .table = (uint16_t []) {
2860 
2861          16,
2862       },
2863    },
2864    [nir_op_fsin] = {
2865       .filter = (uint16_t []) {
2866          0,
2867          0,
2868          0,
2869          0,
2870          0,
2871          0,
2872          0,
2873          0,
2874          0,
2875          0,
2876          0,
2877          0,
2878          0,
2879          0,
2880          0,
2881          0,
2882          0,
2883          0,
2884          0,
2885          0,
2886          0,
2887          0,
2888       },
2889 
2890       .num_filtered_states = 1,
2891       .table = (uint16_t []) {
2892 
2893          17,
2894       },
2895    },
2896    [nir_op_fcos] = {
2897       .filter = (uint16_t []) {
2898          0,
2899          0,
2900          0,
2901          0,
2902          0,
2903          0,
2904          0,
2905          0,
2906          0,
2907          0,
2908          0,
2909          0,
2910          0,
2911          0,
2912          0,
2913          0,
2914          0,
2915          0,
2916          0,
2917          0,
2918          0,
2919          0,
2920       },
2921 
2922       .num_filtered_states = 1,
2923       .table = (uint16_t []) {
2924 
2925          18,
2926       },
2927    },
2928    [nir_search_op_f2b] = {
2929       .filter = (uint16_t []) {
2930          0,
2931          0,
2932          0,
2933          0,
2934          0,
2935          0,
2936          0,
2937          0,
2938          0,
2939          0,
2940          0,
2941          0,
2942          0,
2943          0,
2944          0,
2945          0,
2946          0,
2947          0,
2948          0,
2949          0,
2950          0,
2951          0,
2952       },
2953 
2954       .num_filtered_states = 1,
2955       .table = (uint16_t []) {
2956 
2957          19,
2958       },
2959    },
2960    [nir_search_op_i2b] = {
2961       .filter = (uint16_t []) {
2962          0,
2963          0,
2964          0,
2965          0,
2966          0,
2967          0,
2968          0,
2969          0,
2970          0,
2971          0,
2972          0,
2973          0,
2974          0,
2975          0,
2976          0,
2977          0,
2978          0,
2979          0,
2980          0,
2981          0,
2982          0,
2983          0,
2984       },
2985 
2986       .num_filtered_states = 1,
2987       .table = (uint16_t []) {
2988 
2989          20,
2990       },
2991    },
2992    [nir_search_op_b2i] = {
2993       .filter = (uint16_t []) {
2994          0,
2995          0,
2996          0,
2997          0,
2998          0,
2999          0,
3000          0,
3001          0,
3002          0,
3003          0,
3004          0,
3005          0,
3006          0,
3007          0,
3008          0,
3009          0,
3010          0,
3011          0,
3012          0,
3013          0,
3014          0,
3015          0,
3016       },
3017 
3018       .num_filtered_states = 1,
3019       .table = (uint16_t []) {
3020 
3021          21,
3022       },
3023    },
3024 };
3025 
3026 const struct transform *bifrost_nir_lower_algebraic_late_transforms[] = {
3027    NULL,
3028    NULL,
3029    bifrost_nir_lower_algebraic_late_state2_xforms,
3030    bifrost_nir_lower_algebraic_late_state3_xforms,
3031    bifrost_nir_lower_algebraic_late_state4_xforms,
3032    bifrost_nir_lower_algebraic_late_state5_xforms,
3033    bifrost_nir_lower_algebraic_late_state6_xforms,
3034    bifrost_nir_lower_algebraic_late_state7_xforms,
3035    bifrost_nir_lower_algebraic_late_state8_xforms,
3036    bifrost_nir_lower_algebraic_late_state9_xforms,
3037    bifrost_nir_lower_algebraic_late_state10_xforms,
3038    bifrost_nir_lower_algebraic_late_state11_xforms,
3039    bifrost_nir_lower_algebraic_late_state12_xforms,
3040    bifrost_nir_lower_algebraic_late_state13_xforms,
3041    bifrost_nir_lower_algebraic_late_state14_xforms,
3042    bifrost_nir_lower_algebraic_late_state15_xforms,
3043    bifrost_nir_lower_algebraic_late_state16_xforms,
3044    bifrost_nir_lower_algebraic_late_state17_xforms,
3045    bifrost_nir_lower_algebraic_late_state18_xforms,
3046    bifrost_nir_lower_algebraic_late_state19_xforms,
3047    bifrost_nir_lower_algebraic_late_state20_xforms,
3048    bifrost_nir_lower_algebraic_late_state21_xforms,
3049 };
3050 
3051 const uint16_t bifrost_nir_lower_algebraic_late_transform_counts[] = {
3052    0,
3053    0,
3054    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state2_xforms),
3055    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state3_xforms),
3056    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state4_xforms),
3057    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state5_xforms),
3058    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state6_xforms),
3059    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state7_xforms),
3060    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state8_xforms),
3061    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state9_xforms),
3062    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state10_xforms),
3063    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state11_xforms),
3064    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state12_xforms),
3065    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state13_xforms),
3066    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state14_xforms),
3067    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state15_xforms),
3068    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state16_xforms),
3069    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state17_xforms),
3070    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state18_xforms),
3071    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state19_xforms),
3072    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state20_xforms),
3073    (uint16_t)ARRAY_SIZE(bifrost_nir_lower_algebraic_late_state21_xforms),
3074 };
3075 
3076 bool
bifrost_nir_lower_algebraic_late(nir_shader * shader)3077 bifrost_nir_lower_algebraic_late(nir_shader *shader)
3078 {
3079    bool progress = false;
3080    bool condition_flags[1];
3081    const nir_shader_compiler_options *options = shader->options;
3082    const shader_info *info = &shader->info;
3083    (void) options;
3084    (void) info;
3085 
3086    condition_flags[0] = true;
3087 
3088    nir_foreach_function(function, shader) {
3089       if (function->impl) {
3090          progress |= nir_algebraic_impl(function->impl, condition_flags,
3091                                         bifrost_nir_lower_algebraic_late_transforms,
3092                                         bifrost_nir_lower_algebraic_late_transform_counts,
3093                                         bifrost_nir_lower_algebraic_late_table);
3094       }
3095    }
3096 
3097    return progress;
3098 }
3099 
3100