1#include "midgard_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 1 9 * transforms: 10 * ('~fadd', ('fadd', 'a', 'b'), 'a') => ('fadd', ('fadd', 'a', 'a'), 'b') 11 */ 12 13 14 static const nir_search_variable search0_0_0 = { 15 { nir_search_value_variable, -2 }, 16 0, /* a */ 17 false, 18 nir_type_invalid, 19 NULL, 20 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 21}; 22 23static const nir_search_variable search0_0_1 = { 24 { nir_search_value_variable, -2 }, 25 1, /* b */ 26 false, 27 nir_type_invalid, 28 NULL, 29 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 30}; 31static const nir_search_expression search0_0 = { 32 { nir_search_value_expression, -2 }, 33 false, false, 34 1, 1, 35 nir_op_fadd, 36 { &search0_0_0.value, &search0_0_1.value }, 37 NULL, 38}; 39 40/* search0_1 -> search0_0_0 in the cache */ 41static const nir_search_expression search0 = { 42 { nir_search_value_expression, -2 }, 43 true, false, 44 0, 2, 45 nir_op_fadd, 46 { &search0_0.value, &search0_0_0.value }, 47 NULL, 48}; 49 50 /* replace0_0_0 -> search0_0_0 in the cache */ 51 52/* replace0_0_1 -> search0_0_0 in the cache */ 53static const nir_search_expression replace0_0 = { 54 { nir_search_value_expression, -2 }, 55 false, false, 56 -1, 0, 57 nir_op_fadd, 58 { &search0_0_0.value, &search0_0_0.value }, 59 NULL, 60}; 61 62/* replace0_1 -> search0_0_1 in the cache */ 63static const nir_search_expression replace0 = { 64 { nir_search_value_expression, -2 }, 65 false, false, 66 0, 1, 67 nir_op_fadd, 68 { &replace0_0.value, &search0_0_1.value }, 69 NULL, 70}; 71 72 73static const struct transform midgard_nir_lower_algebraic_early_state3_xforms[] = { 74 { &search0, &replace0.value, 0 }, 75}; 76 77static const struct per_op_table midgard_nir_lower_algebraic_early_table[nir_num_search_ops] = { 78 [nir_op_fadd] = { 79 .filter = (uint16_t []) { 80 0, 81 0, 82 1, 83 1, 84 }, 85 86 .num_filtered_states = 2, 87 .table = (uint16_t []) { 88 89 2, 90 3, 91 3, 92 3, 93 }, 94 }, 95}; 96 97const struct transform *midgard_nir_lower_algebraic_early_transforms[] = { 98 NULL, 99 NULL, 100 NULL, 101 midgard_nir_lower_algebraic_early_state3_xforms, 102}; 103 104const uint16_t midgard_nir_lower_algebraic_early_transform_counts[] = { 105 0, 106 0, 107 0, 108 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_early_state3_xforms), 109}; 110 111bool 112midgard_nir_lower_algebraic_early(nir_shader *shader) 113{ 114 bool progress = false; 115 bool condition_flags[1]; 116 const nir_shader_compiler_options *options = shader->options; 117 const shader_info *info = &shader->info; 118 (void) options; 119 (void) info; 120 121 condition_flags[0] = true; 122 123 nir_foreach_function(function, shader) { 124 if (function->impl) { 125 progress |= nir_algebraic_impl(function->impl, condition_flags, 126 midgard_nir_lower_algebraic_early_transforms, 127 midgard_nir_lower_algebraic_early_transform_counts, 128 midgard_nir_lower_algebraic_early_table); 129 } 130 } 131 132 return progress; 133} 134 135 136#include "nir.h" 137#include "nir_builder.h" 138#include "nir_search.h" 139#include "nir_search_helpers.h" 140 141/* What follows is NIR algebraic transform code for the following 54 142 * transforms: 143 * ('ineg', 'a') => ('isub', 0, 'a') 144 * ('fsub', 'a', 'b') => ('fadd', 'a', ('fneg', 'b')) 145 * ('b32csel', 'a', 'b@32', 0) => ('iand', 'a', 'b') 146 * ('b32csel', 'a', 0, 'b@32') => ('iand', ('inot', 'a'), 'b') 147 * ('~fmin', ('fmax', 'a', -1.0), 1.0) => ('fsat_signed_mali', 'a') 148 * ('~fmax', ('fmin', 'a', 1.0), -1.0) => ('fsat_signed_mali', 'a') 149 * ('fmax', 'a', 0.0) => ('fclamp_pos_mali', 'a') 150 * ('ishl', 'a@16', 'b') => ('u2u16', ('ishl', ('u2u32', 'a'), 'b')) 151 * ('ishr', 'a@16', 'b') => ('i2i16', ('ishr', ('i2i32', 'a'), 'b')) 152 * ('ushr', 'a@16', 'b') => ('u2u16', ('ushr', ('u2u32', 'a'), 'b')) 153 * ('ishl', 'a@8', 'b') => ('u2u8', ('u2u16', ('ishl', ('u2u32', ('u2u16', 'a')), 'b'))) 154 * ('ishr', 'a@8', 'b') => ('i2i8', ('i2i16', ('ishr', ('i2i32', ('i2i16', 'a')), 'b'))) 155 * ('ushr', 'a@8', 'b') => ('u2u8', ('u2u16', ('ushr', ('u2u32', ('u2u16', 'a')), 'b'))) 156 * ('fmul', 'a', 2.0) => ('fadd', 'a', 'a') 157 * ('ufind_msb', 'a@8') => ('isub', 31, ('uclz', ('u2u32', 'a'))) 158 * ('ufind_msb', 'a@16') => ('isub', 31, ('uclz', ('u2u32', 'a'))) 159 * ('ufind_msb', 'a@32') => ('isub', 31, ('uclz', 'a')) 160 * ('u2u8', 'a@32') => ('u2u8', ('u2u16', 'a')) 161 * ('u2u8', 'a@64') => ('u2u8', ('u2u16', ('u2u32', 'a'))) 162 * ('u2u16', 'a@64') => ('u2u16', ('u2u32', 'a')) 163 * ('u2u32', 'a@8') => ('u2u32', ('u2u16', 'a')) 164 * ('u2u64', 'a@8') => ('u2u64', ('u2u32', ('u2u16', 'a'))) 165 * ('u2u64', 'a@16') => ('u2u64', ('u2u32', 'a')) 166 * ('i2i8', 'a@32') => ('i2i8', ('i2i16', 'a')) 167 * ('i2i8', 'a@64') => ('i2i8', ('i2i16', ('i2i32', 'a'))) 168 * ('i2i16', 'a@64') => ('i2i16', ('i2i32', 'a')) 169 * ('i2i32', 'a@8') => ('i2i32', ('i2i16', 'a')) 170 * ('i2i64', 'a@8') => ('i2i64', ('i2i32', ('i2i16', 'a'))) 171 * ('i2i64', 'a@16') => ('i2i64', ('i2i32', 'a')) 172 * ('f2f16', 'a@64') => ('f2f16', ('f2f32', 'a')) 173 * ('f2f64', 'a@16') => ('f2f64', ('f2f32', 'a')) 174 * ('i2f16', 'a@64') => ('f2f16', ('f2f32', ('i2f64', 'a'))) 175 * ('i2f32', 'a@8') => ('i2f32', ('i2i32', ('i2i16', 'a'))) 176 * ('i2f64', 'a@8') => ('i2f64', ('i2i64', ('i2i32', ('i2i16', 'a')))) 177 * ('i2f64', 'a@16') => ('i2f64', ('i2i64', ('i2i32', 'a'))) 178 * ('u2f16', 'a@64') => ('f2f16', ('f2f32', ('u2f64', 'a'))) 179 * ('u2f32', 'a@8') => ('u2f32', ('u2u32', ('u2u16', 'a'))) 180 * ('u2f64', 'a@8') => ('u2f64', ('u2u64', ('u2u32', ('u2u16', 'a')))) 181 * ('u2f64', 'a@16') => ('u2f64', ('u2u64', ('u2u32', 'a'))) 182 * ('f2i8', 'a@32') => ('i2i8', ('i2i16', ('f2i32', 'a'))) 183 * ('f2i8', 'a@64') => ('i2i8', ('i2i16', ('i2i32', ('f2i64', 'a')))) 184 * ('f2i16', 'a@64') => ('i2i16', ('i2i32', ('f2i64', 'a'))) 185 * ('f2i64', 'a@16') => ('f2i64', ('f2f64', ('f2f32', 'a'))) 186 * ('f2u8', 'a@32') => ('u2u8', ('u2u16', ('f2u32', 'a'))) 187 * ('f2u8', 'a@64') => ('u2u8', ('u2u16', ('u2u32', ('f2u64', 'a')))) 188 * ('f2u16', 'a@64') => ('u2u16', ('u2u32', ('f2u64', 'a'))) 189 * ('f2u64', 'a@16') => ('f2u64', ('f2f64', ('f2f32', 'a'))) 190 * ('fge', 'a', '#b') => ('inot', ('flt', 'a', 'b')) 191 * ('fge32', 'a', '#b') => ('inot', ('flt32', 'a', 'b')) 192 * ('ige32', 'a', '#b') => ('inot', ('ilt32', 'a', 'b')) 193 * ('uge32', 'a', '#b') => ('inot', ('ult32', 'a', 'b')) 194 * ('flt32', '#a', 'b') => ('inot', ('fge32', 'a', 'b')) 195 * ('ilt32', '#a', 'b') => ('inot', ('ige32', 'a', 'b')) 196 * ('ult32', '#a', 'b') => ('inot', ('uge32', 'a', 'b')) 197 */ 198 199 200 static const nir_search_variable search1_0 = { 201 { nir_search_value_variable, -1 }, 202 0, /* a */ 203 false, 204 nir_type_invalid, 205 NULL, 206 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 207}; 208static const nir_search_expression search1 = { 209 { nir_search_value_expression, -1 }, 210 false, false, 211 -1, 0, 212 nir_op_ineg, 213 { &search1_0.value }, 214 NULL, 215}; 216 217 static const nir_search_constant replace1_0 = { 218 { nir_search_value_constant, -1 }, 219 nir_type_int, { 0x0 /* 0 */ }, 220}; 221 222/* replace1_1 -> search1_0 in the cache */ 223static const nir_search_expression replace1 = { 224 { nir_search_value_expression, -1 }, 225 false, false, 226 -1, 0, 227 nir_op_isub, 228 { &replace1_0.value, &search1_0.value }, 229 NULL, 230}; 231 232 static const nir_search_variable search2_0 = { 233 { nir_search_value_variable, -2 }, 234 0, /* a */ 235 false, 236 nir_type_invalid, 237 NULL, 238 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 239}; 240 241static const nir_search_variable search2_1 = { 242 { nir_search_value_variable, -2 }, 243 1, /* b */ 244 false, 245 nir_type_invalid, 246 NULL, 247 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 248}; 249static const nir_search_expression search2 = { 250 { nir_search_value_expression, -2 }, 251 false, false, 252 -1, 0, 253 nir_op_fsub, 254 { &search2_0.value, &search2_1.value }, 255 NULL, 256}; 257 258 /* replace2_0 -> search2_0 in the cache */ 259 260/* replace2_1_0 -> search2_1 in the cache */ 261static const nir_search_expression replace2_1 = { 262 { nir_search_value_expression, -2 }, 263 false, false, 264 -1, 0, 265 nir_op_fneg, 266 { &search2_1.value }, 267 NULL, 268}; 269static const nir_search_expression replace2 = { 270 { nir_search_value_expression, -2 }, 271 false, false, 272 0, 1, 273 nir_op_fadd, 274 { &search2_0.value, &replace2_1.value }, 275 NULL, 276}; 277 278 static const nir_search_variable search3_0 = { 279 { nir_search_value_variable, 32 }, 280 0, /* a */ 281 false, 282 nir_type_invalid, 283 NULL, 284 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 285}; 286 287static const nir_search_variable search3_1 = { 288 { nir_search_value_variable, 32 }, 289 1, /* b */ 290 false, 291 nir_type_invalid, 292 NULL, 293 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 294}; 295 296static const nir_search_constant search3_2 = { 297 { nir_search_value_constant, 32 }, 298 nir_type_int, { 0x0 /* 0 */ }, 299}; 300static const nir_search_expression search3 = { 301 { nir_search_value_expression, 32 }, 302 false, false, 303 -1, 0, 304 nir_op_b32csel, 305 { &search3_0.value, &search3_1.value, &search3_2.value }, 306 NULL, 307}; 308 309 /* replace3_0 -> search3_0 in the cache */ 310 311/* replace3_1 -> search3_1 in the cache */ 312static const nir_search_expression replace3 = { 313 { nir_search_value_expression, 32 }, 314 false, false, 315 0, 1, 316 nir_op_iand, 317 { &search3_0.value, &search3_1.value }, 318 NULL, 319}; 320 321 /* search4_0 -> search3_0 in the cache */ 322 323/* search4_1 -> search3_2 in the cache */ 324 325/* search4_2 -> search3_1 in the cache */ 326static const nir_search_expression search4 = { 327 { nir_search_value_expression, 32 }, 328 false, false, 329 -1, 0, 330 nir_op_b32csel, 331 { &search3_0.value, &search3_2.value, &search3_1.value }, 332 NULL, 333}; 334 335 /* replace4_0_0 -> search3_0 in the cache */ 336static const nir_search_expression replace4_0 = { 337 { nir_search_value_expression, 32 }, 338 false, false, 339 -1, 0, 340 nir_op_inot, 341 { &search3_0.value }, 342 NULL, 343}; 344 345/* replace4_1 -> search3_1 in the cache */ 346static const nir_search_expression replace4 = { 347 { nir_search_value_expression, 32 }, 348 false, false, 349 0, 1, 350 nir_op_iand, 351 { &replace4_0.value, &search3_1.value }, 352 NULL, 353}; 354 355 /* search5_0_0 -> search1_0 in the cache */ 356 357static const nir_search_constant search5_0_1 = { 358 { nir_search_value_constant, -1 }, 359 nir_type_float, { 0xbff0000000000000 /* -1.0 */ }, 360}; 361static const nir_search_expression search5_0 = { 362 { nir_search_value_expression, -1 }, 363 false, false, 364 1, 1, 365 nir_op_fmax, 366 { &search1_0.value, &search5_0_1.value }, 367 NULL, 368}; 369 370static const nir_search_constant search5_1 = { 371 { nir_search_value_constant, -1 }, 372 nir_type_float, { 0x3ff0000000000000 /* 1.0 */ }, 373}; 374static const nir_search_expression search5 = { 375 { nir_search_value_expression, -1 }, 376 true, false, 377 0, 2, 378 nir_op_fmin, 379 { &search5_0.value, &search5_1.value }, 380 NULL, 381}; 382 383 /* replace5_0 -> search1_0 in the cache */ 384static const nir_search_expression replace5 = { 385 { nir_search_value_expression, -1 }, 386 false, false, 387 -1, 0, 388 nir_op_fsat_signed_mali, 389 { &search1_0.value }, 390 NULL, 391}; 392 393 /* search6_0_0 -> search1_0 in the cache */ 394 395/* search6_0_1 -> search5_1 in the cache */ 396static const nir_search_expression search6_0 = { 397 { nir_search_value_expression, -1 }, 398 false, false, 399 1, 1, 400 nir_op_fmin, 401 { &search1_0.value, &search5_1.value }, 402 NULL, 403}; 404 405/* search6_1 -> search5_0_1 in the cache */ 406static const nir_search_expression search6 = { 407 { nir_search_value_expression, -1 }, 408 true, false, 409 0, 2, 410 nir_op_fmax, 411 { &search6_0.value, &search5_0_1.value }, 412 NULL, 413}; 414 415 /* replace6_0 -> search1_0 in the cache */ 416/* replace6 -> replace5 in the cache */ 417 418 /* search7_0 -> search1_0 in the cache */ 419 420static const nir_search_constant search7_1 = { 421 { nir_search_value_constant, -1 }, 422 nir_type_float, { 0x0 /* 0.0 */ }, 423}; 424static const nir_search_expression search7 = { 425 { nir_search_value_expression, -1 }, 426 false, false, 427 0, 1, 428 nir_op_fmax, 429 { &search1_0.value, &search7_1.value }, 430 NULL, 431}; 432 433 /* replace7_0 -> search1_0 in the cache */ 434static const nir_search_expression replace7 = { 435 { nir_search_value_expression, -1 }, 436 false, false, 437 -1, 0, 438 nir_op_fclamp_pos_mali, 439 { &search1_0.value }, 440 NULL, 441}; 442 443 static const nir_search_variable search8_0 = { 444 { nir_search_value_variable, 16 }, 445 0, /* a */ 446 false, 447 nir_type_invalid, 448 NULL, 449 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 450}; 451 452/* search8_1 -> search3_1 in the cache */ 453static const nir_search_expression search8 = { 454 { nir_search_value_expression, 16 }, 455 false, false, 456 -1, 0, 457 nir_op_ishl, 458 { &search8_0.value, &search3_1.value }, 459 NULL, 460}; 461 462 /* replace8_0_0_0 -> search8_0 in the cache */ 463static const nir_search_expression replace8_0_0 = { 464 { nir_search_value_expression, 32 }, 465 false, false, 466 -1, 0, 467 nir_op_u2u32, 468 { &search8_0.value }, 469 NULL, 470}; 471 472/* replace8_0_1 -> search3_1 in the cache */ 473static const nir_search_expression replace8_0 = { 474 { nir_search_value_expression, 32 }, 475 false, false, 476 -1, 0, 477 nir_op_ishl, 478 { &replace8_0_0.value, &search3_1.value }, 479 NULL, 480}; 481static const nir_search_expression replace8 = { 482 { nir_search_value_expression, 16 }, 483 false, false, 484 -1, 0, 485 nir_op_u2u16, 486 { &replace8_0.value }, 487 NULL, 488}; 489 490 /* search9_0 -> search8_0 in the cache */ 491 492/* search9_1 -> search3_1 in the cache */ 493static const nir_search_expression search9 = { 494 { nir_search_value_expression, 16 }, 495 false, false, 496 -1, 0, 497 nir_op_ishr, 498 { &search8_0.value, &search3_1.value }, 499 NULL, 500}; 501 502 /* replace9_0_0_0 -> search8_0 in the cache */ 503static const nir_search_expression replace9_0_0 = { 504 { nir_search_value_expression, 32 }, 505 false, false, 506 -1, 0, 507 nir_op_i2i32, 508 { &search8_0.value }, 509 NULL, 510}; 511 512/* replace9_0_1 -> search3_1 in the cache */ 513static const nir_search_expression replace9_0 = { 514 { nir_search_value_expression, 32 }, 515 false, false, 516 -1, 0, 517 nir_op_ishr, 518 { &replace9_0_0.value, &search3_1.value }, 519 NULL, 520}; 521static const nir_search_expression replace9 = { 522 { nir_search_value_expression, 16 }, 523 false, false, 524 -1, 0, 525 nir_op_i2i16, 526 { &replace9_0.value }, 527 NULL, 528}; 529 530 /* search10_0 -> search8_0 in the cache */ 531 532/* search10_1 -> search3_1 in the cache */ 533static const nir_search_expression search10 = { 534 { nir_search_value_expression, 16 }, 535 false, false, 536 -1, 0, 537 nir_op_ushr, 538 { &search8_0.value, &search3_1.value }, 539 NULL, 540}; 541 542 /* replace10_0_0_0 -> search8_0 in the cache */ 543/* replace10_0_0 -> replace8_0_0 in the cache */ 544 545/* replace10_0_1 -> search3_1 in the cache */ 546static const nir_search_expression replace10_0 = { 547 { nir_search_value_expression, 32 }, 548 false, false, 549 -1, 0, 550 nir_op_ushr, 551 { &replace8_0_0.value, &search3_1.value }, 552 NULL, 553}; 554static const nir_search_expression replace10 = { 555 { nir_search_value_expression, 16 }, 556 false, false, 557 -1, 0, 558 nir_op_u2u16, 559 { &replace10_0.value }, 560 NULL, 561}; 562 563 static const nir_search_variable search11_0 = { 564 { nir_search_value_variable, 8 }, 565 0, /* a */ 566 false, 567 nir_type_invalid, 568 NULL, 569 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 570}; 571 572/* search11_1 -> search3_1 in the cache */ 573static const nir_search_expression search11 = { 574 { nir_search_value_expression, 8 }, 575 false, false, 576 -1, 0, 577 nir_op_ishl, 578 { &search11_0.value, &search3_1.value }, 579 NULL, 580}; 581 582 /* replace11_0_0_0_0_0 -> search11_0 in the cache */ 583static const nir_search_expression replace11_0_0_0_0 = { 584 { nir_search_value_expression, 16 }, 585 false, false, 586 -1, 0, 587 nir_op_u2u16, 588 { &search11_0.value }, 589 NULL, 590}; 591static const nir_search_expression replace11_0_0_0 = { 592 { nir_search_value_expression, 32 }, 593 false, false, 594 -1, 0, 595 nir_op_u2u32, 596 { &replace11_0_0_0_0.value }, 597 NULL, 598}; 599 600/* replace11_0_0_1 -> search3_1 in the cache */ 601static const nir_search_expression replace11_0_0 = { 602 { nir_search_value_expression, 32 }, 603 false, false, 604 -1, 0, 605 nir_op_ishl, 606 { &replace11_0_0_0.value, &search3_1.value }, 607 NULL, 608}; 609static const nir_search_expression replace11_0 = { 610 { nir_search_value_expression, 16 }, 611 false, false, 612 -1, 0, 613 nir_op_u2u16, 614 { &replace11_0_0.value }, 615 NULL, 616}; 617static const nir_search_expression replace11 = { 618 { nir_search_value_expression, 8 }, 619 false, false, 620 -1, 0, 621 nir_op_u2u8, 622 { &replace11_0.value }, 623 NULL, 624}; 625 626 /* search12_0 -> search11_0 in the cache */ 627 628/* search12_1 -> search3_1 in the cache */ 629static const nir_search_expression search12 = { 630 { nir_search_value_expression, 8 }, 631 false, false, 632 -1, 0, 633 nir_op_ishr, 634 { &search11_0.value, &search3_1.value }, 635 NULL, 636}; 637 638 /* replace12_0_0_0_0_0 -> search11_0 in the cache */ 639static const nir_search_expression replace12_0_0_0_0 = { 640 { nir_search_value_expression, 16 }, 641 false, false, 642 -1, 0, 643 nir_op_i2i16, 644 { &search11_0.value }, 645 NULL, 646}; 647static const nir_search_expression replace12_0_0_0 = { 648 { nir_search_value_expression, 32 }, 649 false, false, 650 -1, 0, 651 nir_op_i2i32, 652 { &replace12_0_0_0_0.value }, 653 NULL, 654}; 655 656/* replace12_0_0_1 -> search3_1 in the cache */ 657static const nir_search_expression replace12_0_0 = { 658 { nir_search_value_expression, 32 }, 659 false, false, 660 -1, 0, 661 nir_op_ishr, 662 { &replace12_0_0_0.value, &search3_1.value }, 663 NULL, 664}; 665static const nir_search_expression replace12_0 = { 666 { nir_search_value_expression, 16 }, 667 false, false, 668 -1, 0, 669 nir_op_i2i16, 670 { &replace12_0_0.value }, 671 NULL, 672}; 673static const nir_search_expression replace12 = { 674 { nir_search_value_expression, 8 }, 675 false, false, 676 -1, 0, 677 nir_op_i2i8, 678 { &replace12_0.value }, 679 NULL, 680}; 681 682 /* search13_0 -> search11_0 in the cache */ 683 684/* search13_1 -> search3_1 in the cache */ 685static const nir_search_expression search13 = { 686 { nir_search_value_expression, 8 }, 687 false, false, 688 -1, 0, 689 nir_op_ushr, 690 { &search11_0.value, &search3_1.value }, 691 NULL, 692}; 693 694 /* replace13_0_0_0_0_0 -> search11_0 in the cache */ 695/* replace13_0_0_0_0 -> replace11_0_0_0_0 in the cache */ 696/* replace13_0_0_0 -> replace11_0_0_0 in the cache */ 697 698/* replace13_0_0_1 -> search3_1 in the cache */ 699static const nir_search_expression replace13_0_0 = { 700 { nir_search_value_expression, 32 }, 701 false, false, 702 -1, 0, 703 nir_op_ushr, 704 { &replace11_0_0_0.value, &search3_1.value }, 705 NULL, 706}; 707static const nir_search_expression replace13_0 = { 708 { nir_search_value_expression, 16 }, 709 false, false, 710 -1, 0, 711 nir_op_u2u16, 712 { &replace13_0_0.value }, 713 NULL, 714}; 715static const nir_search_expression replace13 = { 716 { nir_search_value_expression, 8 }, 717 false, false, 718 -1, 0, 719 nir_op_u2u8, 720 { &replace13_0.value }, 721 NULL, 722}; 723 724 /* search14_0 -> search1_0 in the cache */ 725 726static const nir_search_constant search14_1 = { 727 { nir_search_value_constant, -1 }, 728 nir_type_float, { 0x4000000000000000 /* 2.0 */ }, 729}; 730static const nir_search_expression search14 = { 731 { nir_search_value_expression, -1 }, 732 false, false, 733 0, 1, 734 nir_op_fmul, 735 { &search1_0.value, &search14_1.value }, 736 NULL, 737}; 738 739 /* replace14_0 -> search1_0 in the cache */ 740 741/* replace14_1 -> search1_0 in the cache */ 742static const nir_search_expression replace14 = { 743 { nir_search_value_expression, -1 }, 744 false, false, 745 -1, 0, 746 nir_op_fadd, 747 { &search1_0.value, &search1_0.value }, 748 NULL, 749}; 750 751 /* search15_0 -> search11_0 in the cache */ 752static const nir_search_expression search15 = { 753 { nir_search_value_expression, 32 }, 754 false, false, 755 -1, 0, 756 nir_op_ufind_msb, 757 { &search11_0.value }, 758 NULL, 759}; 760 761 static const nir_search_constant replace15_0 = { 762 { nir_search_value_constant, 32 }, 763 nir_type_int, { 0x1f /* 31 */ }, 764}; 765 766/* replace15_1_0_0 -> search11_0 in the cache */ 767static const nir_search_expression replace15_1_0 = { 768 { nir_search_value_expression, 32 }, 769 false, false, 770 -1, 0, 771 nir_op_u2u32, 772 { &search11_0.value }, 773 NULL, 774}; 775static const nir_search_expression replace15_1 = { 776 { nir_search_value_expression, 32 }, 777 false, false, 778 -1, 0, 779 nir_op_uclz, 780 { &replace15_1_0.value }, 781 NULL, 782}; 783static const nir_search_expression replace15 = { 784 { nir_search_value_expression, 32 }, 785 false, false, 786 -1, 0, 787 nir_op_isub, 788 { &replace15_0.value, &replace15_1.value }, 789 NULL, 790}; 791 792 /* search16_0 -> search8_0 in the cache */ 793static const nir_search_expression search16 = { 794 { nir_search_value_expression, 32 }, 795 false, false, 796 -1, 0, 797 nir_op_ufind_msb, 798 { &search8_0.value }, 799 NULL, 800}; 801 802 /* replace16_0 -> replace15_0 in the cache */ 803 804/* replace16_1_0_0 -> search8_0 in the cache */ 805/* replace16_1_0 -> replace8_0_0 in the cache */ 806static const nir_search_expression replace16_1 = { 807 { nir_search_value_expression, 32 }, 808 false, false, 809 -1, 0, 810 nir_op_uclz, 811 { &replace8_0_0.value }, 812 NULL, 813}; 814static const nir_search_expression replace16 = { 815 { nir_search_value_expression, 32 }, 816 false, false, 817 -1, 0, 818 nir_op_isub, 819 { &replace15_0.value, &replace16_1.value }, 820 NULL, 821}; 822 823 /* search17_0 -> search3_0 in the cache */ 824static const nir_search_expression search17 = { 825 { nir_search_value_expression, 32 }, 826 false, false, 827 -1, 0, 828 nir_op_ufind_msb, 829 { &search3_0.value }, 830 NULL, 831}; 832 833 /* replace17_0 -> replace15_0 in the cache */ 834 835/* replace17_1_0 -> search3_0 in the cache */ 836static const nir_search_expression replace17_1 = { 837 { nir_search_value_expression, 32 }, 838 false, false, 839 -1, 0, 840 nir_op_uclz, 841 { &search3_0.value }, 842 NULL, 843}; 844static const nir_search_expression replace17 = { 845 { nir_search_value_expression, 32 }, 846 false, false, 847 -1, 0, 848 nir_op_isub, 849 { &replace15_0.value, &replace17_1.value }, 850 NULL, 851}; 852 853 /* search18_0 -> search3_0 in the cache */ 854static const nir_search_expression search18 = { 855 { nir_search_value_expression, 8 }, 856 false, false, 857 -1, 0, 858 nir_op_u2u8, 859 { &search3_0.value }, 860 NULL, 861}; 862 863 /* replace18_0_0 -> search3_0 in the cache */ 864static const nir_search_expression replace18_0 = { 865 { nir_search_value_expression, 16 }, 866 false, false, 867 -1, 0, 868 nir_op_u2u16, 869 { &search3_0.value }, 870 NULL, 871}; 872static const nir_search_expression replace18 = { 873 { nir_search_value_expression, 8 }, 874 false, false, 875 -1, 0, 876 nir_op_u2u8, 877 { &replace18_0.value }, 878 NULL, 879}; 880 881 static const nir_search_variable search19_0 = { 882 { nir_search_value_variable, 64 }, 883 0, /* a */ 884 false, 885 nir_type_invalid, 886 NULL, 887 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 888}; 889static const nir_search_expression search19 = { 890 { nir_search_value_expression, 8 }, 891 false, false, 892 -1, 0, 893 nir_op_u2u8, 894 { &search19_0.value }, 895 NULL, 896}; 897 898 /* replace19_0_0_0 -> search19_0 in the cache */ 899static const nir_search_expression replace19_0_0 = { 900 { nir_search_value_expression, 32 }, 901 false, false, 902 -1, 0, 903 nir_op_u2u32, 904 { &search19_0.value }, 905 NULL, 906}; 907static const nir_search_expression replace19_0 = { 908 { nir_search_value_expression, 16 }, 909 false, false, 910 -1, 0, 911 nir_op_u2u16, 912 { &replace19_0_0.value }, 913 NULL, 914}; 915static const nir_search_expression replace19 = { 916 { nir_search_value_expression, 8 }, 917 false, false, 918 -1, 0, 919 nir_op_u2u8, 920 { &replace19_0.value }, 921 NULL, 922}; 923 924 /* search20_0 -> search19_0 in the cache */ 925static const nir_search_expression search20 = { 926 { nir_search_value_expression, 16 }, 927 false, false, 928 -1, 0, 929 nir_op_u2u16, 930 { &search19_0.value }, 931 NULL, 932}; 933 934 /* replace20_0_0 -> search19_0 in the cache */ 935/* replace20_0 -> replace19_0_0 in the cache */ 936/* replace20 -> replace19_0 in the cache */ 937 938 /* search21_0 -> search11_0 in the cache */ 939/* search21 -> replace15_1_0 in the cache */ 940 941 /* replace21_0_0 -> search11_0 in the cache */ 942/* replace21_0 -> replace11_0_0_0_0 in the cache */ 943/* replace21 -> replace11_0_0_0 in the cache */ 944 945 /* search22_0 -> search11_0 in the cache */ 946static const nir_search_expression search22 = { 947 { nir_search_value_expression, 64 }, 948 false, false, 949 -1, 0, 950 nir_op_u2u64, 951 { &search11_0.value }, 952 NULL, 953}; 954 955 /* replace22_0_0_0 -> search11_0 in the cache */ 956/* replace22_0_0 -> replace11_0_0_0_0 in the cache */ 957/* replace22_0 -> replace11_0_0_0 in the cache */ 958static const nir_search_expression replace22 = { 959 { nir_search_value_expression, 64 }, 960 false, false, 961 -1, 0, 962 nir_op_u2u64, 963 { &replace11_0_0_0.value }, 964 NULL, 965}; 966 967 /* search23_0 -> search8_0 in the cache */ 968static const nir_search_expression search23 = { 969 { nir_search_value_expression, 64 }, 970 false, false, 971 -1, 0, 972 nir_op_u2u64, 973 { &search8_0.value }, 974 NULL, 975}; 976 977 /* replace23_0_0 -> search8_0 in the cache */ 978/* replace23_0 -> replace8_0_0 in the cache */ 979static const nir_search_expression replace23 = { 980 { nir_search_value_expression, 64 }, 981 false, false, 982 -1, 0, 983 nir_op_u2u64, 984 { &replace8_0_0.value }, 985 NULL, 986}; 987 988 /* search24_0 -> search3_0 in the cache */ 989static const nir_search_expression search24 = { 990 { nir_search_value_expression, 8 }, 991 false, false, 992 -1, 0, 993 nir_op_i2i8, 994 { &search3_0.value }, 995 NULL, 996}; 997 998 /* replace24_0_0 -> search3_0 in the cache */ 999static const nir_search_expression replace24_0 = { 1000 { nir_search_value_expression, 16 }, 1001 false, false, 1002 -1, 0, 1003 nir_op_i2i16, 1004 { &search3_0.value }, 1005 NULL, 1006}; 1007static const nir_search_expression replace24 = { 1008 { nir_search_value_expression, 8 }, 1009 false, false, 1010 -1, 0, 1011 nir_op_i2i8, 1012 { &replace24_0.value }, 1013 NULL, 1014}; 1015 1016 /* search25_0 -> search19_0 in the cache */ 1017static const nir_search_expression search25 = { 1018 { nir_search_value_expression, 8 }, 1019 false, false, 1020 -1, 0, 1021 nir_op_i2i8, 1022 { &search19_0.value }, 1023 NULL, 1024}; 1025 1026 /* replace25_0_0_0 -> search19_0 in the cache */ 1027static const nir_search_expression replace25_0_0 = { 1028 { nir_search_value_expression, 32 }, 1029 false, false, 1030 -1, 0, 1031 nir_op_i2i32, 1032 { &search19_0.value }, 1033 NULL, 1034}; 1035static const nir_search_expression replace25_0 = { 1036 { nir_search_value_expression, 16 }, 1037 false, false, 1038 -1, 0, 1039 nir_op_i2i16, 1040 { &replace25_0_0.value }, 1041 NULL, 1042}; 1043static const nir_search_expression replace25 = { 1044 { nir_search_value_expression, 8 }, 1045 false, false, 1046 -1, 0, 1047 nir_op_i2i8, 1048 { &replace25_0.value }, 1049 NULL, 1050}; 1051 1052 /* search26_0 -> search19_0 in the cache */ 1053static const nir_search_expression search26 = { 1054 { nir_search_value_expression, 16 }, 1055 false, false, 1056 -1, 0, 1057 nir_op_i2i16, 1058 { &search19_0.value }, 1059 NULL, 1060}; 1061 1062 /* replace26_0_0 -> search19_0 in the cache */ 1063/* replace26_0 -> replace25_0_0 in the cache */ 1064/* replace26 -> replace25_0 in the cache */ 1065 1066 /* search27_0 -> search11_0 in the cache */ 1067static const nir_search_expression search27 = { 1068 { nir_search_value_expression, 32 }, 1069 false, false, 1070 -1, 0, 1071 nir_op_i2i32, 1072 { &search11_0.value }, 1073 NULL, 1074}; 1075 1076 /* replace27_0_0 -> search11_0 in the cache */ 1077/* replace27_0 -> replace12_0_0_0_0 in the cache */ 1078/* replace27 -> replace12_0_0_0 in the cache */ 1079 1080 /* search28_0 -> search11_0 in the cache */ 1081static const nir_search_expression search28 = { 1082 { nir_search_value_expression, 64 }, 1083 false, false, 1084 -1, 0, 1085 nir_op_i2i64, 1086 { &search11_0.value }, 1087 NULL, 1088}; 1089 1090 /* replace28_0_0_0 -> search11_0 in the cache */ 1091/* replace28_0_0 -> replace12_0_0_0_0 in the cache */ 1092/* replace28_0 -> replace12_0_0_0 in the cache */ 1093static const nir_search_expression replace28 = { 1094 { nir_search_value_expression, 64 }, 1095 false, false, 1096 -1, 0, 1097 nir_op_i2i64, 1098 { &replace12_0_0_0.value }, 1099 NULL, 1100}; 1101 1102 /* search29_0 -> search8_0 in the cache */ 1103static const nir_search_expression search29 = { 1104 { nir_search_value_expression, 64 }, 1105 false, false, 1106 -1, 0, 1107 nir_op_i2i64, 1108 { &search8_0.value }, 1109 NULL, 1110}; 1111 1112 /* replace29_0_0 -> search8_0 in the cache */ 1113/* replace29_0 -> replace9_0_0 in the cache */ 1114static const nir_search_expression replace29 = { 1115 { nir_search_value_expression, 64 }, 1116 false, false, 1117 -1, 0, 1118 nir_op_i2i64, 1119 { &replace9_0_0.value }, 1120 NULL, 1121}; 1122 1123 /* search30_0 -> search19_0 in the cache */ 1124static const nir_search_expression search30 = { 1125 { nir_search_value_expression, 16 }, 1126 false, false, 1127 -1, 0, 1128 nir_op_f2f16, 1129 { &search19_0.value }, 1130 NULL, 1131}; 1132 1133 /* replace30_0_0 -> search19_0 in the cache */ 1134static const nir_search_expression replace30_0 = { 1135 { nir_search_value_expression, 32 }, 1136 false, false, 1137 -1, 0, 1138 nir_op_f2f32, 1139 { &search19_0.value }, 1140 NULL, 1141}; 1142static const nir_search_expression replace30 = { 1143 { nir_search_value_expression, 16 }, 1144 false, false, 1145 -1, 0, 1146 nir_op_f2f16, 1147 { &replace30_0.value }, 1148 NULL, 1149}; 1150 1151 /* search31_0 -> search8_0 in the cache */ 1152static const nir_search_expression search31 = { 1153 { nir_search_value_expression, 64 }, 1154 false, false, 1155 -1, 0, 1156 nir_op_f2f64, 1157 { &search8_0.value }, 1158 NULL, 1159}; 1160 1161 /* replace31_0_0 -> search8_0 in the cache */ 1162static const nir_search_expression replace31_0 = { 1163 { nir_search_value_expression, 32 }, 1164 false, false, 1165 -1, 0, 1166 nir_op_f2f32, 1167 { &search8_0.value }, 1168 NULL, 1169}; 1170static const nir_search_expression replace31 = { 1171 { nir_search_value_expression, 64 }, 1172 false, false, 1173 -1, 0, 1174 nir_op_f2f64, 1175 { &replace31_0.value }, 1176 NULL, 1177}; 1178 1179 /* search32_0 -> search19_0 in the cache */ 1180static const nir_search_expression search32 = { 1181 { nir_search_value_expression, 16 }, 1182 false, false, 1183 -1, 0, 1184 nir_op_i2f16, 1185 { &search19_0.value }, 1186 NULL, 1187}; 1188 1189 /* replace32_0_0_0 -> search19_0 in the cache */ 1190static const nir_search_expression replace32_0_0 = { 1191 { nir_search_value_expression, 64 }, 1192 false, false, 1193 -1, 0, 1194 nir_op_i2f64, 1195 { &search19_0.value }, 1196 NULL, 1197}; 1198static const nir_search_expression replace32_0 = { 1199 { nir_search_value_expression, 32 }, 1200 false, false, 1201 -1, 0, 1202 nir_op_f2f32, 1203 { &replace32_0_0.value }, 1204 NULL, 1205}; 1206static const nir_search_expression replace32 = { 1207 { nir_search_value_expression, 16 }, 1208 false, false, 1209 -1, 0, 1210 nir_op_f2f16, 1211 { &replace32_0.value }, 1212 NULL, 1213}; 1214 1215 /* search33_0 -> search11_0 in the cache */ 1216static const nir_search_expression search33 = { 1217 { nir_search_value_expression, 32 }, 1218 false, false, 1219 -1, 0, 1220 nir_op_i2f32, 1221 { &search11_0.value }, 1222 NULL, 1223}; 1224 1225 /* replace33_0_0_0 -> search11_0 in the cache */ 1226/* replace33_0_0 -> replace12_0_0_0_0 in the cache */ 1227/* replace33_0 -> replace12_0_0_0 in the cache */ 1228static const nir_search_expression replace33 = { 1229 { nir_search_value_expression, 32 }, 1230 false, false, 1231 -1, 0, 1232 nir_op_i2f32, 1233 { &replace12_0_0_0.value }, 1234 NULL, 1235}; 1236 1237 /* search34_0 -> search11_0 in the cache */ 1238static const nir_search_expression search34 = { 1239 { nir_search_value_expression, 64 }, 1240 false, false, 1241 -1, 0, 1242 nir_op_i2f64, 1243 { &search11_0.value }, 1244 NULL, 1245}; 1246 1247 /* replace34_0_0_0_0 -> search11_0 in the cache */ 1248/* replace34_0_0_0 -> replace12_0_0_0_0 in the cache */ 1249/* replace34_0_0 -> replace12_0_0_0 in the cache */ 1250/* replace34_0 -> replace28 in the cache */ 1251static const nir_search_expression replace34 = { 1252 { nir_search_value_expression, 64 }, 1253 false, false, 1254 -1, 0, 1255 nir_op_i2f64, 1256 { &replace28.value }, 1257 NULL, 1258}; 1259 1260 /* search35_0 -> search8_0 in the cache */ 1261static const nir_search_expression search35 = { 1262 { nir_search_value_expression, 64 }, 1263 false, false, 1264 -1, 0, 1265 nir_op_i2f64, 1266 { &search8_0.value }, 1267 NULL, 1268}; 1269 1270 /* replace35_0_0_0 -> search8_0 in the cache */ 1271/* replace35_0_0 -> replace9_0_0 in the cache */ 1272/* replace35_0 -> replace29 in the cache */ 1273static const nir_search_expression replace35 = { 1274 { nir_search_value_expression, 64 }, 1275 false, false, 1276 -1, 0, 1277 nir_op_i2f64, 1278 { &replace29.value }, 1279 NULL, 1280}; 1281 1282 /* search36_0 -> search19_0 in the cache */ 1283static const nir_search_expression search36 = { 1284 { nir_search_value_expression, 16 }, 1285 false, false, 1286 -1, 0, 1287 nir_op_u2f16, 1288 { &search19_0.value }, 1289 NULL, 1290}; 1291 1292 /* replace36_0_0_0 -> search19_0 in the cache */ 1293static const nir_search_expression replace36_0_0 = { 1294 { nir_search_value_expression, 64 }, 1295 false, false, 1296 -1, 0, 1297 nir_op_u2f64, 1298 { &search19_0.value }, 1299 NULL, 1300}; 1301static const nir_search_expression replace36_0 = { 1302 { nir_search_value_expression, 32 }, 1303 false, false, 1304 -1, 0, 1305 nir_op_f2f32, 1306 { &replace36_0_0.value }, 1307 NULL, 1308}; 1309static const nir_search_expression replace36 = { 1310 { nir_search_value_expression, 16 }, 1311 false, false, 1312 -1, 0, 1313 nir_op_f2f16, 1314 { &replace36_0.value }, 1315 NULL, 1316}; 1317 1318 /* search37_0 -> search11_0 in the cache */ 1319static const nir_search_expression search37 = { 1320 { nir_search_value_expression, 32 }, 1321 false, false, 1322 -1, 0, 1323 nir_op_u2f32, 1324 { &search11_0.value }, 1325 NULL, 1326}; 1327 1328 /* replace37_0_0_0 -> search11_0 in the cache */ 1329/* replace37_0_0 -> replace11_0_0_0_0 in the cache */ 1330/* replace37_0 -> replace11_0_0_0 in the cache */ 1331static const nir_search_expression replace37 = { 1332 { nir_search_value_expression, 32 }, 1333 false, false, 1334 -1, 0, 1335 nir_op_u2f32, 1336 { &replace11_0_0_0.value }, 1337 NULL, 1338}; 1339 1340 /* search38_0 -> search11_0 in the cache */ 1341static const nir_search_expression search38 = { 1342 { nir_search_value_expression, 64 }, 1343 false, false, 1344 -1, 0, 1345 nir_op_u2f64, 1346 { &search11_0.value }, 1347 NULL, 1348}; 1349 1350 /* replace38_0_0_0_0 -> search11_0 in the cache */ 1351/* replace38_0_0_0 -> replace11_0_0_0_0 in the cache */ 1352/* replace38_0_0 -> replace11_0_0_0 in the cache */ 1353/* replace38_0 -> replace22 in the cache */ 1354static const nir_search_expression replace38 = { 1355 { nir_search_value_expression, 64 }, 1356 false, false, 1357 -1, 0, 1358 nir_op_u2f64, 1359 { &replace22.value }, 1360 NULL, 1361}; 1362 1363 /* search39_0 -> search8_0 in the cache */ 1364static const nir_search_expression search39 = { 1365 { nir_search_value_expression, 64 }, 1366 false, false, 1367 -1, 0, 1368 nir_op_u2f64, 1369 { &search8_0.value }, 1370 NULL, 1371}; 1372 1373 /* replace39_0_0_0 -> search8_0 in the cache */ 1374/* replace39_0_0 -> replace8_0_0 in the cache */ 1375/* replace39_0 -> replace23 in the cache */ 1376static const nir_search_expression replace39 = { 1377 { nir_search_value_expression, 64 }, 1378 false, false, 1379 -1, 0, 1380 nir_op_u2f64, 1381 { &replace23.value }, 1382 NULL, 1383}; 1384 1385 /* search40_0 -> search3_0 in the cache */ 1386static const nir_search_expression search40 = { 1387 { nir_search_value_expression, 8 }, 1388 false, false, 1389 -1, 0, 1390 nir_op_f2i8, 1391 { &search3_0.value }, 1392 NULL, 1393}; 1394 1395 /* replace40_0_0_0 -> search3_0 in the cache */ 1396static const nir_search_expression replace40_0_0 = { 1397 { nir_search_value_expression, 32 }, 1398 false, false, 1399 -1, 0, 1400 nir_op_f2i32, 1401 { &search3_0.value }, 1402 NULL, 1403}; 1404static const nir_search_expression replace40_0 = { 1405 { nir_search_value_expression, 16 }, 1406 false, false, 1407 -1, 0, 1408 nir_op_i2i16, 1409 { &replace40_0_0.value }, 1410 NULL, 1411}; 1412static const nir_search_expression replace40 = { 1413 { nir_search_value_expression, 8 }, 1414 false, false, 1415 -1, 0, 1416 nir_op_i2i8, 1417 { &replace40_0.value }, 1418 NULL, 1419}; 1420 1421 /* search41_0 -> search19_0 in the cache */ 1422static const nir_search_expression search41 = { 1423 { nir_search_value_expression, 8 }, 1424 false, false, 1425 -1, 0, 1426 nir_op_f2i8, 1427 { &search19_0.value }, 1428 NULL, 1429}; 1430 1431 /* replace41_0_0_0_0 -> search19_0 in the cache */ 1432static const nir_search_expression replace41_0_0_0 = { 1433 { nir_search_value_expression, 64 }, 1434 false, false, 1435 -1, 0, 1436 nir_op_f2i64, 1437 { &search19_0.value }, 1438 NULL, 1439}; 1440static const nir_search_expression replace41_0_0 = { 1441 { nir_search_value_expression, 32 }, 1442 false, false, 1443 -1, 0, 1444 nir_op_i2i32, 1445 { &replace41_0_0_0.value }, 1446 NULL, 1447}; 1448static const nir_search_expression replace41_0 = { 1449 { nir_search_value_expression, 16 }, 1450 false, false, 1451 -1, 0, 1452 nir_op_i2i16, 1453 { &replace41_0_0.value }, 1454 NULL, 1455}; 1456static const nir_search_expression replace41 = { 1457 { nir_search_value_expression, 8 }, 1458 false, false, 1459 -1, 0, 1460 nir_op_i2i8, 1461 { &replace41_0.value }, 1462 NULL, 1463}; 1464 1465 /* search42_0 -> search19_0 in the cache */ 1466static const nir_search_expression search42 = { 1467 { nir_search_value_expression, 16 }, 1468 false, false, 1469 -1, 0, 1470 nir_op_f2i16, 1471 { &search19_0.value }, 1472 NULL, 1473}; 1474 1475 /* replace42_0_0_0 -> search19_0 in the cache */ 1476/* replace42_0_0 -> replace41_0_0_0 in the cache */ 1477/* replace42_0 -> replace41_0_0 in the cache */ 1478/* replace42 -> replace41_0 in the cache */ 1479 1480 /* search43_0 -> search8_0 in the cache */ 1481static const nir_search_expression search43 = { 1482 { nir_search_value_expression, 64 }, 1483 false, false, 1484 -1, 0, 1485 nir_op_f2i64, 1486 { &search8_0.value }, 1487 NULL, 1488}; 1489 1490 /* replace43_0_0_0 -> search8_0 in the cache */ 1491/* replace43_0_0 -> replace31_0 in the cache */ 1492/* replace43_0 -> replace31 in the cache */ 1493static const nir_search_expression replace43 = { 1494 { nir_search_value_expression, 64 }, 1495 false, false, 1496 -1, 0, 1497 nir_op_f2i64, 1498 { &replace31.value }, 1499 NULL, 1500}; 1501 1502 /* search44_0 -> search3_0 in the cache */ 1503static const nir_search_expression search44 = { 1504 { nir_search_value_expression, 8 }, 1505 false, false, 1506 -1, 0, 1507 nir_op_f2u8, 1508 { &search3_0.value }, 1509 NULL, 1510}; 1511 1512 /* replace44_0_0_0 -> search3_0 in the cache */ 1513static const nir_search_expression replace44_0_0 = { 1514 { nir_search_value_expression, 32 }, 1515 false, false, 1516 -1, 0, 1517 nir_op_f2u32, 1518 { &search3_0.value }, 1519 NULL, 1520}; 1521static const nir_search_expression replace44_0 = { 1522 { nir_search_value_expression, 16 }, 1523 false, false, 1524 -1, 0, 1525 nir_op_u2u16, 1526 { &replace44_0_0.value }, 1527 NULL, 1528}; 1529static const nir_search_expression replace44 = { 1530 { nir_search_value_expression, 8 }, 1531 false, false, 1532 -1, 0, 1533 nir_op_u2u8, 1534 { &replace44_0.value }, 1535 NULL, 1536}; 1537 1538 /* search45_0 -> search19_0 in the cache */ 1539static const nir_search_expression search45 = { 1540 { nir_search_value_expression, 8 }, 1541 false, false, 1542 -1, 0, 1543 nir_op_f2u8, 1544 { &search19_0.value }, 1545 NULL, 1546}; 1547 1548 /* replace45_0_0_0_0 -> search19_0 in the cache */ 1549static const nir_search_expression replace45_0_0_0 = { 1550 { nir_search_value_expression, 64 }, 1551 false, false, 1552 -1, 0, 1553 nir_op_f2u64, 1554 { &search19_0.value }, 1555 NULL, 1556}; 1557static const nir_search_expression replace45_0_0 = { 1558 { nir_search_value_expression, 32 }, 1559 false, false, 1560 -1, 0, 1561 nir_op_u2u32, 1562 { &replace45_0_0_0.value }, 1563 NULL, 1564}; 1565static const nir_search_expression replace45_0 = { 1566 { nir_search_value_expression, 16 }, 1567 false, false, 1568 -1, 0, 1569 nir_op_u2u16, 1570 { &replace45_0_0.value }, 1571 NULL, 1572}; 1573static const nir_search_expression replace45 = { 1574 { nir_search_value_expression, 8 }, 1575 false, false, 1576 -1, 0, 1577 nir_op_u2u8, 1578 { &replace45_0.value }, 1579 NULL, 1580}; 1581 1582 /* search46_0 -> search19_0 in the cache */ 1583static const nir_search_expression search46 = { 1584 { nir_search_value_expression, 16 }, 1585 false, false, 1586 -1, 0, 1587 nir_op_f2u16, 1588 { &search19_0.value }, 1589 NULL, 1590}; 1591 1592 /* replace46_0_0_0 -> search19_0 in the cache */ 1593/* replace46_0_0 -> replace45_0_0_0 in the cache */ 1594/* replace46_0 -> replace45_0_0 in the cache */ 1595/* replace46 -> replace45_0 in the cache */ 1596 1597 /* search47_0 -> search8_0 in the cache */ 1598static const nir_search_expression search47 = { 1599 { nir_search_value_expression, 64 }, 1600 false, false, 1601 -1, 0, 1602 nir_op_f2u64, 1603 { &search8_0.value }, 1604 NULL, 1605}; 1606 1607 /* replace47_0_0_0 -> search8_0 in the cache */ 1608/* replace47_0_0 -> replace31_0 in the cache */ 1609/* replace47_0 -> replace31 in the cache */ 1610static const nir_search_expression replace47 = { 1611 { nir_search_value_expression, 64 }, 1612 false, false, 1613 -1, 0, 1614 nir_op_f2u64, 1615 { &replace31.value }, 1616 NULL, 1617}; 1618 1619 /* search48_0 -> search2_0 in the cache */ 1620 1621static const nir_search_variable search48_1 = { 1622 { nir_search_value_variable, -2 }, 1623 1, /* b */ 1624 true, 1625 nir_type_invalid, 1626 NULL, 1627 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 1628}; 1629static const nir_search_expression search48 = { 1630 { nir_search_value_expression, 1 }, 1631 false, false, 1632 -1, 0, 1633 nir_op_fge, 1634 { &search2_0.value, &search48_1.value }, 1635 NULL, 1636}; 1637 1638 /* replace48_0_0 -> search2_0 in the cache */ 1639 1640/* replace48_0_1 -> search2_1 in the cache */ 1641static const nir_search_expression replace48_0 = { 1642 { nir_search_value_expression, 1 }, 1643 false, false, 1644 -1, 0, 1645 nir_op_flt, 1646 { &search2_0.value, &search2_1.value }, 1647 NULL, 1648}; 1649static const nir_search_expression replace48 = { 1650 { nir_search_value_expression, 1 }, 1651 false, false, 1652 -1, 0, 1653 nir_op_inot, 1654 { &replace48_0.value }, 1655 NULL, 1656}; 1657 1658 /* search49_0 -> search2_0 in the cache */ 1659 1660/* search49_1 -> search48_1 in the cache */ 1661static const nir_search_expression search49 = { 1662 { nir_search_value_expression, 32 }, 1663 false, false, 1664 -1, 0, 1665 nir_op_fge32, 1666 { &search2_0.value, &search48_1.value }, 1667 NULL, 1668}; 1669 1670 /* replace49_0_0 -> search2_0 in the cache */ 1671 1672/* replace49_0_1 -> search2_1 in the cache */ 1673static const nir_search_expression replace49_0 = { 1674 { nir_search_value_expression, 32 }, 1675 false, false, 1676 -1, 0, 1677 nir_op_flt32, 1678 { &search2_0.value, &search2_1.value }, 1679 NULL, 1680}; 1681static const nir_search_expression replace49 = { 1682 { nir_search_value_expression, 32 }, 1683 false, false, 1684 -1, 0, 1685 nir_op_inot, 1686 { &replace49_0.value }, 1687 NULL, 1688}; 1689 1690 /* search50_0 -> search2_0 in the cache */ 1691 1692/* search50_1 -> search48_1 in the cache */ 1693static const nir_search_expression search50 = { 1694 { nir_search_value_expression, 32 }, 1695 false, false, 1696 -1, 0, 1697 nir_op_ige32, 1698 { &search2_0.value, &search48_1.value }, 1699 NULL, 1700}; 1701 1702 /* replace50_0_0 -> search2_0 in the cache */ 1703 1704/* replace50_0_1 -> search2_1 in the cache */ 1705static const nir_search_expression replace50_0 = { 1706 { nir_search_value_expression, 32 }, 1707 false, false, 1708 -1, 0, 1709 nir_op_ilt32, 1710 { &search2_0.value, &search2_1.value }, 1711 NULL, 1712}; 1713static const nir_search_expression replace50 = { 1714 { nir_search_value_expression, 32 }, 1715 false, false, 1716 -1, 0, 1717 nir_op_inot, 1718 { &replace50_0.value }, 1719 NULL, 1720}; 1721 1722 /* search51_0 -> search2_0 in the cache */ 1723 1724/* search51_1 -> search48_1 in the cache */ 1725static const nir_search_expression search51 = { 1726 { nir_search_value_expression, 32 }, 1727 false, false, 1728 -1, 0, 1729 nir_op_uge32, 1730 { &search2_0.value, &search48_1.value }, 1731 NULL, 1732}; 1733 1734 /* replace51_0_0 -> search2_0 in the cache */ 1735 1736/* replace51_0_1 -> search2_1 in the cache */ 1737static const nir_search_expression replace51_0 = { 1738 { nir_search_value_expression, 32 }, 1739 false, false, 1740 -1, 0, 1741 nir_op_ult32, 1742 { &search2_0.value, &search2_1.value }, 1743 NULL, 1744}; 1745static const nir_search_expression replace51 = { 1746 { nir_search_value_expression, 32 }, 1747 false, false, 1748 -1, 0, 1749 nir_op_inot, 1750 { &replace51_0.value }, 1751 NULL, 1752}; 1753 1754 static const nir_search_variable search52_0 = { 1755 { nir_search_value_variable, -2 }, 1756 0, /* a */ 1757 true, 1758 nir_type_invalid, 1759 NULL, 1760 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 1761}; 1762 1763/* search52_1 -> search2_1 in the cache */ 1764static const nir_search_expression search52 = { 1765 { nir_search_value_expression, 32 }, 1766 false, false, 1767 -1, 0, 1768 nir_op_flt32, 1769 { &search52_0.value, &search2_1.value }, 1770 NULL, 1771}; 1772 1773 /* replace52_0_0 -> search2_0 in the cache */ 1774 1775/* replace52_0_1 -> search2_1 in the cache */ 1776static const nir_search_expression replace52_0 = { 1777 { nir_search_value_expression, 32 }, 1778 false, false, 1779 -1, 0, 1780 nir_op_fge32, 1781 { &search2_0.value, &search2_1.value }, 1782 NULL, 1783}; 1784static const nir_search_expression replace52 = { 1785 { nir_search_value_expression, 32 }, 1786 false, false, 1787 -1, 0, 1788 nir_op_inot, 1789 { &replace52_0.value }, 1790 NULL, 1791}; 1792 1793 /* search53_0 -> search52_0 in the cache */ 1794 1795/* search53_1 -> search2_1 in the cache */ 1796static const nir_search_expression search53 = { 1797 { nir_search_value_expression, 32 }, 1798 false, false, 1799 -1, 0, 1800 nir_op_ilt32, 1801 { &search52_0.value, &search2_1.value }, 1802 NULL, 1803}; 1804 1805 /* replace53_0_0 -> search2_0 in the cache */ 1806 1807/* replace53_0_1 -> search2_1 in the cache */ 1808static const nir_search_expression replace53_0 = { 1809 { nir_search_value_expression, 32 }, 1810 false, false, 1811 -1, 0, 1812 nir_op_ige32, 1813 { &search2_0.value, &search2_1.value }, 1814 NULL, 1815}; 1816static const nir_search_expression replace53 = { 1817 { nir_search_value_expression, 32 }, 1818 false, false, 1819 -1, 0, 1820 nir_op_inot, 1821 { &replace53_0.value }, 1822 NULL, 1823}; 1824 1825 /* search54_0 -> search52_0 in the cache */ 1826 1827/* search54_1 -> search2_1 in the cache */ 1828static const nir_search_expression search54 = { 1829 { nir_search_value_expression, 32 }, 1830 false, false, 1831 -1, 0, 1832 nir_op_ult32, 1833 { &search52_0.value, &search2_1.value }, 1834 NULL, 1835}; 1836 1837 /* replace54_0_0 -> search2_0 in the cache */ 1838 1839/* replace54_0_1 -> search2_1 in the cache */ 1840static const nir_search_expression replace54_0 = { 1841 { nir_search_value_expression, 32 }, 1842 false, false, 1843 -1, 0, 1844 nir_op_uge32, 1845 { &search2_0.value, &search2_1.value }, 1846 NULL, 1847}; 1848static const nir_search_expression replace54 = { 1849 { nir_search_value_expression, 32 }, 1850 false, false, 1851 -1, 0, 1852 nir_op_inot, 1853 { &replace54_0.value }, 1854 NULL, 1855}; 1856 1857 1858static const struct transform midgard_nir_lower_algebraic_late_state2_xforms[] = { 1859 { &search1, &replace1.value, 0 }, 1860}; 1861static const struct transform midgard_nir_lower_algebraic_late_state3_xforms[] = { 1862 { &search2, &replace2.value, 0 }, 1863}; 1864static const struct transform midgard_nir_lower_algebraic_late_state4_xforms[] = { 1865 { &search3, &replace3.value, 0 }, 1866}; 1867static const struct transform midgard_nir_lower_algebraic_late_state5_xforms[] = { 1868 { &search4, &replace4.value, 0 }, 1869}; 1870static const struct transform midgard_nir_lower_algebraic_late_state6_xforms[] = { 1871 { &search3, &replace3.value, 0 }, 1872 { &search4, &replace4.value, 0 }, 1873}; 1874static const struct transform midgard_nir_lower_algebraic_late_state8_xforms[] = { 1875 { &search7, &replace7.value, 0 }, 1876}; 1877static const struct transform midgard_nir_lower_algebraic_late_state9_xforms[] = { 1878 { &search8, &replace8.value, 0 }, 1879 { &search11, &replace11.value, 0 }, 1880}; 1881static const struct transform midgard_nir_lower_algebraic_late_state10_xforms[] = { 1882 { &search9, &replace9.value, 0 }, 1883 { &search12, &replace12.value, 0 }, 1884}; 1885static const struct transform midgard_nir_lower_algebraic_late_state11_xforms[] = { 1886 { &search10, &replace10.value, 0 }, 1887 { &search13, &replace13.value, 0 }, 1888}; 1889static const struct transform midgard_nir_lower_algebraic_late_state12_xforms[] = { 1890 { &search14, &replace14.value, 0 }, 1891}; 1892static const struct transform midgard_nir_lower_algebraic_late_state13_xforms[] = { 1893 { &search15, &replace15.value, 0 }, 1894 { &search16, &replace16.value, 0 }, 1895 { &search17, &replace17.value, 0 }, 1896}; 1897static const struct transform midgard_nir_lower_algebraic_late_state14_xforms[] = { 1898 { &search18, &replace18.value, 0 }, 1899 { &search19, &replace19.value, 0 }, 1900 { &search20, &replace19_0.value, 0 }, 1901 { &replace15_1_0, &replace11_0_0_0.value, 0 }, 1902 { &search22, &replace22.value, 0 }, 1903 { &search23, &replace23.value, 0 }, 1904}; 1905static const struct transform midgard_nir_lower_algebraic_late_state15_xforms[] = { 1906 { &search24, &replace24.value, 0 }, 1907 { &search25, &replace25.value, 0 }, 1908 { &search26, &replace25_0.value, 0 }, 1909 { &search27, &replace12_0_0_0.value, 0 }, 1910 { &search28, &replace28.value, 0 }, 1911 { &search29, &replace29.value, 0 }, 1912}; 1913static const struct transform midgard_nir_lower_algebraic_late_state16_xforms[] = { 1914 { &search30, &replace30.value, 0 }, 1915 { &search31, &replace31.value, 0 }, 1916}; 1917static const struct transform midgard_nir_lower_algebraic_late_state17_xforms[] = { 1918 { &search32, &replace32.value, 0 }, 1919 { &search33, &replace33.value, 0 }, 1920 { &search34, &replace34.value, 0 }, 1921 { &search35, &replace35.value, 0 }, 1922}; 1923static const struct transform midgard_nir_lower_algebraic_late_state18_xforms[] = { 1924 { &search36, &replace36.value, 0 }, 1925 { &search37, &replace37.value, 0 }, 1926 { &search38, &replace38.value, 0 }, 1927 { &search39, &replace39.value, 0 }, 1928}; 1929static const struct transform midgard_nir_lower_algebraic_late_state19_xforms[] = { 1930 { &search40, &replace40.value, 0 }, 1931 { &search41, &replace41.value, 0 }, 1932 { &search42, &replace41_0.value, 0 }, 1933 { &search43, &replace43.value, 0 }, 1934}; 1935static const struct transform midgard_nir_lower_algebraic_late_state20_xforms[] = { 1936 { &search44, &replace44.value, 0 }, 1937 { &search45, &replace45.value, 0 }, 1938 { &search46, &replace45_0.value, 0 }, 1939 { &search47, &replace47.value, 0 }, 1940}; 1941static const struct transform midgard_nir_lower_algebraic_late_state21_xforms[] = { 1942 { &search48, &replace48.value, 0 }, 1943}; 1944static const struct transform midgard_nir_lower_algebraic_late_state22_xforms[] = { 1945 { &search49, &replace49.value, 0 }, 1946}; 1947static const struct transform midgard_nir_lower_algebraic_late_state23_xforms[] = { 1948 { &search50, &replace50.value, 0 }, 1949}; 1950static const struct transform midgard_nir_lower_algebraic_late_state24_xforms[] = { 1951 { &search51, &replace51.value, 0 }, 1952}; 1953static const struct transform midgard_nir_lower_algebraic_late_state25_xforms[] = { 1954 { &search52, &replace52.value, 0 }, 1955}; 1956static const struct transform midgard_nir_lower_algebraic_late_state26_xforms[] = { 1957 { &search53, &replace53.value, 0 }, 1958}; 1959static const struct transform midgard_nir_lower_algebraic_late_state27_xforms[] = { 1960 { &search54, &replace54.value, 0 }, 1961}; 1962static const struct transform midgard_nir_lower_algebraic_late_state28_xforms[] = { 1963 { &search6, &replace5.value, 0 }, 1964 { &search7, &replace7.value, 0 }, 1965}; 1966static const struct transform midgard_nir_lower_algebraic_late_state29_xforms[] = { 1967 { &search5, &replace5.value, 0 }, 1968}; 1969 1970static const struct per_op_table midgard_nir_lower_algebraic_late_table[nir_num_search_ops] = { 1971 [nir_op_ineg] = { 1972 .filter = (uint16_t []) { 1973 0, 1974 0, 1975 0, 1976 0, 1977 0, 1978 0, 1979 0, 1980 0, 1981 0, 1982 0, 1983 0, 1984 0, 1985 0, 1986 0, 1987 0, 1988 0, 1989 0, 1990 0, 1991 0, 1992 0, 1993 0, 1994 0, 1995 0, 1996 0, 1997 0, 1998 0, 1999 0, 2000 0, 2001 0, 2002 0, 2003 }, 2004 2005 .num_filtered_states = 1, 2006 .table = (uint16_t []) { 2007 2008 2, 2009 }, 2010 }, 2011 [nir_op_fsub] = { 2012 .filter = (uint16_t []) { 2013 0, 2014 0, 2015 0, 2016 0, 2017 0, 2018 0, 2019 0, 2020 0, 2021 0, 2022 0, 2023 0, 2024 0, 2025 0, 2026 0, 2027 0, 2028 0, 2029 0, 2030 0, 2031 0, 2032 0, 2033 0, 2034 0, 2035 0, 2036 0, 2037 0, 2038 0, 2039 0, 2040 0, 2041 0, 2042 0, 2043 }, 2044 2045 .num_filtered_states = 1, 2046 .table = (uint16_t []) { 2047 2048 3, 2049 }, 2050 }, 2051 [nir_op_b32csel] = { 2052 .filter = (uint16_t []) { 2053 0, 2054 1, 2055 0, 2056 0, 2057 0, 2058 0, 2059 0, 2060 0, 2061 0, 2062 0, 2063 0, 2064 0, 2065 0, 2066 0, 2067 0, 2068 0, 2069 0, 2070 0, 2071 0, 2072 0, 2073 0, 2074 0, 2075 0, 2076 0, 2077 0, 2078 0, 2079 0, 2080 0, 2081 0, 2082 0, 2083 }, 2084 2085 .num_filtered_states = 2, 2086 .table = (uint16_t []) { 2087 2088 0, 2089 4, 2090 5, 2091 6, 2092 0, 2093 4, 2094 5, 2095 6, 2096 }, 2097 }, 2098 [nir_op_fmin] = { 2099 .filter = (uint16_t []) { 2100 0, 2101 1, 2102 0, 2103 0, 2104 0, 2105 0, 2106 0, 2107 0, 2108 2, 2109 0, 2110 0, 2111 0, 2112 0, 2113 0, 2114 0, 2115 0, 2116 0, 2117 0, 2118 0, 2119 0, 2120 0, 2121 0, 2122 0, 2123 0, 2124 0, 2125 0, 2126 0, 2127 0, 2128 2, 2129 0, 2130 }, 2131 2132 .num_filtered_states = 3, 2133 .table = (uint16_t []) { 2134 2135 0, 2136 7, 2137 0, 2138 7, 2139 7, 2140 29, 2141 0, 2142 29, 2143 0, 2144 }, 2145 }, 2146 [nir_op_fmax] = { 2147 .filter = (uint16_t []) { 2148 0, 2149 1, 2150 0, 2151 0, 2152 0, 2153 0, 2154 0, 2155 2, 2156 0, 2157 0, 2158 0, 2159 0, 2160 0, 2161 0, 2162 0, 2163 0, 2164 0, 2165 0, 2166 0, 2167 0, 2168 0, 2169 0, 2170 0, 2171 0, 2172 0, 2173 0, 2174 0, 2175 0, 2176 0, 2177 2, 2178 }, 2179 2180 .num_filtered_states = 3, 2181 .table = (uint16_t []) { 2182 2183 0, 2184 8, 2185 0, 2186 8, 2187 8, 2188 28, 2189 0, 2190 28, 2191 0, 2192 }, 2193 }, 2194 [nir_op_ishl] = { 2195 .filter = (uint16_t []) { 2196 0, 2197 0, 2198 0, 2199 0, 2200 0, 2201 0, 2202 0, 2203 0, 2204 0, 2205 0, 2206 0, 2207 0, 2208 0, 2209 0, 2210 0, 2211 0, 2212 0, 2213 0, 2214 0, 2215 0, 2216 0, 2217 0, 2218 0, 2219 0, 2220 0, 2221 0, 2222 0, 2223 0, 2224 0, 2225 0, 2226 }, 2227 2228 .num_filtered_states = 1, 2229 .table = (uint16_t []) { 2230 2231 9, 2232 }, 2233 }, 2234 [nir_op_ishr] = { 2235 .filter = (uint16_t []) { 2236 0, 2237 0, 2238 0, 2239 0, 2240 0, 2241 0, 2242 0, 2243 0, 2244 0, 2245 0, 2246 0, 2247 0, 2248 0, 2249 0, 2250 0, 2251 0, 2252 0, 2253 0, 2254 0, 2255 0, 2256 0, 2257 0, 2258 0, 2259 0, 2260 0, 2261 0, 2262 0, 2263 0, 2264 0, 2265 0, 2266 }, 2267 2268 .num_filtered_states = 1, 2269 .table = (uint16_t []) { 2270 2271 10, 2272 }, 2273 }, 2274 [nir_op_ushr] = { 2275 .filter = (uint16_t []) { 2276 0, 2277 0, 2278 0, 2279 0, 2280 0, 2281 0, 2282 0, 2283 0, 2284 0, 2285 0, 2286 0, 2287 0, 2288 0, 2289 0, 2290 0, 2291 0, 2292 0, 2293 0, 2294 0, 2295 0, 2296 0, 2297 0, 2298 0, 2299 0, 2300 0, 2301 0, 2302 0, 2303 0, 2304 0, 2305 0, 2306 }, 2307 2308 .num_filtered_states = 1, 2309 .table = (uint16_t []) { 2310 2311 11, 2312 }, 2313 }, 2314 [nir_op_fmul] = { 2315 .filter = (uint16_t []) { 2316 0, 2317 1, 2318 0, 2319 0, 2320 0, 2321 0, 2322 0, 2323 0, 2324 0, 2325 0, 2326 0, 2327 0, 2328 0, 2329 0, 2330 0, 2331 0, 2332 0, 2333 0, 2334 0, 2335 0, 2336 0, 2337 0, 2338 0, 2339 0, 2340 0, 2341 0, 2342 0, 2343 0, 2344 0, 2345 0, 2346 }, 2347 2348 .num_filtered_states = 2, 2349 .table = (uint16_t []) { 2350 2351 0, 2352 12, 2353 12, 2354 12, 2355 }, 2356 }, 2357 [nir_op_ufind_msb] = { 2358 .filter = (uint16_t []) { 2359 0, 2360 0, 2361 0, 2362 0, 2363 0, 2364 0, 2365 0, 2366 0, 2367 0, 2368 0, 2369 0, 2370 0, 2371 0, 2372 0, 2373 0, 2374 0, 2375 0, 2376 0, 2377 0, 2378 0, 2379 0, 2380 0, 2381 0, 2382 0, 2383 0, 2384 0, 2385 0, 2386 0, 2387 0, 2388 0, 2389 }, 2390 2391 .num_filtered_states = 1, 2392 .table = (uint16_t []) { 2393 2394 13, 2395 }, 2396 }, 2397 [nir_search_op_u2u] = { 2398 .filter = (uint16_t []) { 2399 0, 2400 0, 2401 0, 2402 0, 2403 0, 2404 0, 2405 0, 2406 0, 2407 0, 2408 0, 2409 0, 2410 0, 2411 0, 2412 0, 2413 0, 2414 0, 2415 0, 2416 0, 2417 0, 2418 0, 2419 0, 2420 0, 2421 0, 2422 0, 2423 0, 2424 0, 2425 0, 2426 0, 2427 0, 2428 0, 2429 }, 2430 2431 .num_filtered_states = 1, 2432 .table = (uint16_t []) { 2433 2434 14, 2435 }, 2436 }, 2437 [nir_search_op_i2i] = { 2438 .filter = (uint16_t []) { 2439 0, 2440 0, 2441 0, 2442 0, 2443 0, 2444 0, 2445 0, 2446 0, 2447 0, 2448 0, 2449 0, 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 }, 2470 2471 .num_filtered_states = 1, 2472 .table = (uint16_t []) { 2473 2474 15, 2475 }, 2476 }, 2477 [nir_search_op_f2f] = { 2478 .filter = (uint16_t []) { 2479 0, 2480 0, 2481 0, 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 0, 2505 0, 2506 0, 2507 0, 2508 0, 2509 }, 2510 2511 .num_filtered_states = 1, 2512 .table = (uint16_t []) { 2513 2514 16, 2515 }, 2516 }, 2517 [nir_search_op_i2f] = { 2518 .filter = (uint16_t []) { 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 0, 2537 0, 2538 0, 2539 0, 2540 0, 2541 0, 2542 0, 2543 0, 2544 0, 2545 0, 2546 0, 2547 0, 2548 0, 2549 }, 2550 2551 .num_filtered_states = 1, 2552 .table = (uint16_t []) { 2553 2554 17, 2555 }, 2556 }, 2557 [nir_search_op_u2f] = { 2558 .filter = (uint16_t []) { 2559 0, 2560 0, 2561 0, 2562 0, 2563 0, 2564 0, 2565 0, 2566 0, 2567 0, 2568 0, 2569 0, 2570 0, 2571 0, 2572 0, 2573 0, 2574 0, 2575 0, 2576 0, 2577 0, 2578 0, 2579 0, 2580 0, 2581 0, 2582 0, 2583 0, 2584 0, 2585 0, 2586 0, 2587 0, 2588 0, 2589 }, 2590 2591 .num_filtered_states = 1, 2592 .table = (uint16_t []) { 2593 2594 18, 2595 }, 2596 }, 2597 [nir_search_op_f2i] = { 2598 .filter = (uint16_t []) { 2599 0, 2600 0, 2601 0, 2602 0, 2603 0, 2604 0, 2605 0, 2606 0, 2607 0, 2608 0, 2609 0, 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 }, 2630 2631 .num_filtered_states = 1, 2632 .table = (uint16_t []) { 2633 2634 19, 2635 }, 2636 }, 2637 [nir_search_op_f2u] = { 2638 .filter = (uint16_t []) { 2639 0, 2640 0, 2641 0, 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 0, 2665 0, 2666 0, 2667 0, 2668 0, 2669 }, 2670 2671 .num_filtered_states = 1, 2672 .table = (uint16_t []) { 2673 2674 20, 2675 }, 2676 }, 2677 [nir_op_fge] = { 2678 .filter = (uint16_t []) { 2679 0, 2680 1, 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 0, 2697 0, 2698 0, 2699 0, 2700 0, 2701 0, 2702 0, 2703 0, 2704 0, 2705 0, 2706 0, 2707 0, 2708 0, 2709 }, 2710 2711 .num_filtered_states = 2, 2712 .table = (uint16_t []) { 2713 2714 0, 2715 21, 2716 0, 2717 21, 2718 }, 2719 }, 2720 [nir_op_fge32] = { 2721 .filter = (uint16_t []) { 2722 0, 2723 1, 2724 0, 2725 0, 2726 0, 2727 0, 2728 0, 2729 0, 2730 0, 2731 0, 2732 0, 2733 0, 2734 0, 2735 0, 2736 0, 2737 0, 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 }, 2753 2754 .num_filtered_states = 2, 2755 .table = (uint16_t []) { 2756 2757 0, 2758 22, 2759 0, 2760 22, 2761 }, 2762 }, 2763 [nir_op_ige32] = { 2764 .filter = (uint16_t []) { 2765 0, 2766 1, 2767 0, 2768 0, 2769 0, 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 0, 2793 0, 2794 0, 2795 }, 2796 2797 .num_filtered_states = 2, 2798 .table = (uint16_t []) { 2799 2800 0, 2801 23, 2802 0, 2803 23, 2804 }, 2805 }, 2806 [nir_op_uge32] = { 2807 .filter = (uint16_t []) { 2808 0, 2809 1, 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 0, 2825 0, 2826 0, 2827 0, 2828 0, 2829 0, 2830 0, 2831 0, 2832 0, 2833 0, 2834 0, 2835 0, 2836 0, 2837 0, 2838 }, 2839 2840 .num_filtered_states = 2, 2841 .table = (uint16_t []) { 2842 2843 0, 2844 24, 2845 0, 2846 24, 2847 }, 2848 }, 2849 [nir_op_flt32] = { 2850 .filter = (uint16_t []) { 2851 0, 2852 1, 2853 0, 2854 0, 2855 0, 2856 0, 2857 0, 2858 0, 2859 0, 2860 0, 2861 0, 2862 0, 2863 0, 2864 0, 2865 0, 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 }, 2882 2883 .num_filtered_states = 2, 2884 .table = (uint16_t []) { 2885 2886 0, 2887 0, 2888 25, 2889 25, 2890 }, 2891 }, 2892 [nir_op_ilt32] = { 2893 .filter = (uint16_t []) { 2894 0, 2895 1, 2896 0, 2897 0, 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 0, 2921 0, 2922 0, 2923 0, 2924 }, 2925 2926 .num_filtered_states = 2, 2927 .table = (uint16_t []) { 2928 2929 0, 2930 0, 2931 26, 2932 26, 2933 }, 2934 }, 2935 [nir_op_ult32] = { 2936 .filter = (uint16_t []) { 2937 0, 2938 1, 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 0, 2953 0, 2954 0, 2955 0, 2956 0, 2957 0, 2958 0, 2959 0, 2960 0, 2961 0, 2962 0, 2963 0, 2964 0, 2965 0, 2966 0, 2967 }, 2968 2969 .num_filtered_states = 2, 2970 .table = (uint16_t []) { 2971 2972 0, 2973 0, 2974 27, 2975 27, 2976 }, 2977 }, 2978}; 2979 2980const struct transform *midgard_nir_lower_algebraic_late_transforms[] = { 2981 NULL, 2982 NULL, 2983 midgard_nir_lower_algebraic_late_state2_xforms, 2984 midgard_nir_lower_algebraic_late_state3_xforms, 2985 midgard_nir_lower_algebraic_late_state4_xforms, 2986 midgard_nir_lower_algebraic_late_state5_xforms, 2987 midgard_nir_lower_algebraic_late_state6_xforms, 2988 NULL, 2989 midgard_nir_lower_algebraic_late_state8_xforms, 2990 midgard_nir_lower_algebraic_late_state9_xforms, 2991 midgard_nir_lower_algebraic_late_state10_xforms, 2992 midgard_nir_lower_algebraic_late_state11_xforms, 2993 midgard_nir_lower_algebraic_late_state12_xforms, 2994 midgard_nir_lower_algebraic_late_state13_xforms, 2995 midgard_nir_lower_algebraic_late_state14_xforms, 2996 midgard_nir_lower_algebraic_late_state15_xforms, 2997 midgard_nir_lower_algebraic_late_state16_xforms, 2998 midgard_nir_lower_algebraic_late_state17_xforms, 2999 midgard_nir_lower_algebraic_late_state18_xforms, 3000 midgard_nir_lower_algebraic_late_state19_xforms, 3001 midgard_nir_lower_algebraic_late_state20_xforms, 3002 midgard_nir_lower_algebraic_late_state21_xforms, 3003 midgard_nir_lower_algebraic_late_state22_xforms, 3004 midgard_nir_lower_algebraic_late_state23_xforms, 3005 midgard_nir_lower_algebraic_late_state24_xforms, 3006 midgard_nir_lower_algebraic_late_state25_xforms, 3007 midgard_nir_lower_algebraic_late_state26_xforms, 3008 midgard_nir_lower_algebraic_late_state27_xforms, 3009 midgard_nir_lower_algebraic_late_state28_xforms, 3010 midgard_nir_lower_algebraic_late_state29_xforms, 3011}; 3012 3013const uint16_t midgard_nir_lower_algebraic_late_transform_counts[] = { 3014 0, 3015 0, 3016 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state2_xforms), 3017 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state3_xforms), 3018 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state4_xforms), 3019 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state5_xforms), 3020 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state6_xforms), 3021 0, 3022 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state8_xforms), 3023 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state9_xforms), 3024 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state10_xforms), 3025 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state11_xforms), 3026 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state12_xforms), 3027 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state13_xforms), 3028 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state14_xforms), 3029 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state15_xforms), 3030 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state16_xforms), 3031 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state17_xforms), 3032 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state18_xforms), 3033 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state19_xforms), 3034 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state20_xforms), 3035 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state21_xforms), 3036 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state22_xforms), 3037 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state23_xforms), 3038 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state24_xforms), 3039 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state25_xforms), 3040 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state26_xforms), 3041 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state27_xforms), 3042 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state28_xforms), 3043 (uint16_t)ARRAY_SIZE(midgard_nir_lower_algebraic_late_state29_xforms), 3044}; 3045 3046bool 3047midgard_nir_lower_algebraic_late(nir_shader *shader) 3048{ 3049 bool progress = false; 3050 bool condition_flags[1]; 3051 const nir_shader_compiler_options *options = shader->options; 3052 const shader_info *info = &shader->info; 3053 (void) options; 3054 (void) info; 3055 3056 condition_flags[0] = true; 3057 3058 nir_foreach_function(function, shader) { 3059 if (function->impl) { 3060 progress |= nir_algebraic_impl(function->impl, condition_flags, 3061 midgard_nir_lower_algebraic_late_transforms, 3062 midgard_nir_lower_algebraic_late_transform_counts, 3063 midgard_nir_lower_algebraic_late_table); 3064 } 3065 } 3066 3067 return progress; 3068} 3069 3070 3071#include "nir.h" 3072#include "nir_builder.h" 3073#include "nir_search.h" 3074#include "nir_search_helpers.h" 3075 3076/* What follows is NIR algebraic transform code for the following 2 3077 * transforms: 3078 * ('fsin', 'a') => ('fsin', ('fdiv', 'a', 3.141592653589793)) 3079 * ('fcos', 'a') => ('fcos', ('fdiv', 'a', 3.141592653589793)) 3080 */ 3081 3082 3083 static const nir_search_variable search55_0 = { 3084 { nir_search_value_variable, -1 }, 3085 0, /* a */ 3086 false, 3087 nir_type_invalid, 3088 NULL, 3089 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 3090}; 3091static const nir_search_expression search55 = { 3092 { nir_search_value_expression, -1 }, 3093 false, false, 3094 -1, 0, 3095 nir_op_fsin, 3096 { &search55_0.value }, 3097 NULL, 3098}; 3099 3100 /* replace55_0_0 -> search55_0 in the cache */ 3101 3102static const nir_search_constant replace55_0_1 = { 3103 { nir_search_value_constant, -1 }, 3104 nir_type_float, { 0x400921fb54442d18 /* 3.141592653589793 */ }, 3105}; 3106static const nir_search_expression replace55_0 = { 3107 { nir_search_value_expression, -1 }, 3108 false, false, 3109 -1, 0, 3110 nir_op_fdiv, 3111 { &search55_0.value, &replace55_0_1.value }, 3112 NULL, 3113}; 3114static const nir_search_expression replace55 = { 3115 { nir_search_value_expression, -1 }, 3116 false, false, 3117 -1, 0, 3118 nir_op_fsin, 3119 { &replace55_0.value }, 3120 NULL, 3121}; 3122 3123 /* search56_0 -> search55_0 in the cache */ 3124static const nir_search_expression search56 = { 3125 { nir_search_value_expression, -1 }, 3126 false, false, 3127 -1, 0, 3128 nir_op_fcos, 3129 { &search55_0.value }, 3130 NULL, 3131}; 3132 3133 /* replace56_0_0 -> search55_0 in the cache */ 3134 3135/* replace56_0_1 -> replace55_0_1 in the cache */ 3136/* replace56_0 -> replace55_0 in the cache */ 3137static const nir_search_expression replace56 = { 3138 { nir_search_value_expression, -1 }, 3139 false, false, 3140 -1, 0, 3141 nir_op_fcos, 3142 { &replace55_0.value }, 3143 NULL, 3144}; 3145 3146 3147static const struct transform midgard_nir_scale_trig_state2_xforms[] = { 3148 { &search55, &replace55.value, 0 }, 3149}; 3150static const struct transform midgard_nir_scale_trig_state3_xforms[] = { 3151 { &search56, &replace56.value, 0 }, 3152}; 3153 3154static const struct per_op_table midgard_nir_scale_trig_table[nir_num_search_ops] = { 3155 [nir_op_fsin] = { 3156 .filter = (uint16_t []) { 3157 0, 3158 0, 3159 0, 3160 0, 3161 }, 3162 3163 .num_filtered_states = 1, 3164 .table = (uint16_t []) { 3165 3166 2, 3167 }, 3168 }, 3169 [nir_op_fcos] = { 3170 .filter = (uint16_t []) { 3171 0, 3172 0, 3173 0, 3174 0, 3175 }, 3176 3177 .num_filtered_states = 1, 3178 .table = (uint16_t []) { 3179 3180 3, 3181 }, 3182 }, 3183}; 3184 3185const struct transform *midgard_nir_scale_trig_transforms[] = { 3186 NULL, 3187 NULL, 3188 midgard_nir_scale_trig_state2_xforms, 3189 midgard_nir_scale_trig_state3_xforms, 3190}; 3191 3192const uint16_t midgard_nir_scale_trig_transform_counts[] = { 3193 0, 3194 0, 3195 (uint16_t)ARRAY_SIZE(midgard_nir_scale_trig_state2_xforms), 3196 (uint16_t)ARRAY_SIZE(midgard_nir_scale_trig_state3_xforms), 3197}; 3198 3199bool 3200midgard_nir_scale_trig(nir_shader *shader) 3201{ 3202 bool progress = false; 3203 bool condition_flags[1]; 3204 const nir_shader_compiler_options *options = shader->options; 3205 const shader_info *info = &shader->info; 3206 (void) options; 3207 (void) info; 3208 3209 condition_flags[0] = true; 3210 3211 nir_foreach_function(function, shader) { 3212 if (function->impl) { 3213 progress |= nir_algebraic_impl(function->impl, condition_flags, 3214 midgard_nir_scale_trig_transforms, 3215 midgard_nir_scale_trig_transform_counts, 3216 midgard_nir_scale_trig_table); 3217 } 3218 } 3219 3220 return progress; 3221} 3222 3223 3224#include "nir.h" 3225#include "nir_builder.h" 3226#include "nir_search.h" 3227#include "nir_search_helpers.h" 3228 3229/* What follows is NIR algebraic transform code for the following 1 3230 * transforms: 3231 * ('inot', ('inot', 'a')) => a 3232 */ 3233 3234 3235 static const nir_search_variable search57_0_0 = { 3236 { nir_search_value_variable, -1 }, 3237 0, /* a */ 3238 false, 3239 nir_type_invalid, 3240 NULL, 3241 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, 3242}; 3243static const nir_search_expression search57_0 = { 3244 { nir_search_value_expression, -1 }, 3245 false, false, 3246 -1, 0, 3247 nir_op_inot, 3248 { &search57_0_0.value }, 3249 NULL, 3250}; 3251static const nir_search_expression search57 = { 3252 { nir_search_value_expression, -1 }, 3253 false, false, 3254 -1, 0, 3255 nir_op_inot, 3256 { &search57_0.value }, 3257 NULL, 3258}; 3259 3260 /* replace57 -> search57_0_0 in the cache */ 3261 3262 3263static const struct transform midgard_nir_cancel_inot_state3_xforms[] = { 3264 { &search57, &search57_0_0.value, 0 }, 3265}; 3266 3267static const struct per_op_table midgard_nir_cancel_inot_table[nir_num_search_ops] = { 3268 [nir_op_inot] = { 3269 .filter = (uint16_t []) { 3270 0, 3271 0, 3272 1, 3273 1, 3274 }, 3275 3276 .num_filtered_states = 2, 3277 .table = (uint16_t []) { 3278 3279 2, 3280 3, 3281 }, 3282 }, 3283}; 3284 3285const struct transform *midgard_nir_cancel_inot_transforms[] = { 3286 NULL, 3287 NULL, 3288 NULL, 3289 midgard_nir_cancel_inot_state3_xforms, 3290}; 3291 3292const uint16_t midgard_nir_cancel_inot_transform_counts[] = { 3293 0, 3294 0, 3295 0, 3296 (uint16_t)ARRAY_SIZE(midgard_nir_cancel_inot_state3_xforms), 3297}; 3298 3299bool 3300midgard_nir_cancel_inot(nir_shader *shader) 3301{ 3302 bool progress = false; 3303 bool condition_flags[1]; 3304 const nir_shader_compiler_options *options = shader->options; 3305 const shader_info *info = &shader->info; 3306 (void) options; 3307 (void) info; 3308 3309 condition_flags[0] = true; 3310 3311 nir_foreach_function(function, shader) { 3312 if (function->impl) { 3313 progress |= nir_algebraic_impl(function->impl, condition_flags, 3314 midgard_nir_cancel_inot_transforms, 3315 midgard_nir_cancel_inot_transform_counts, 3316 midgard_nir_cancel_inot_table); 3317 } 3318 } 3319 3320 return progress; 3321} 3322 3323