Home | History | Annotate | Download | only in nir
      1 /*
      2  * Copyright (C) 2014 Intel Corporation
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the "Software"),
      6  * to deal in the Software without restriction, including without limitation
      7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8  * and/or sell copies of the Software, and to permit persons to whom the
      9  * Software is furnished to do so, subject to the following conditions:
     10  *
     11  * The above copyright notice and this permission notice (including the next
     12  * paragraph) shall be included in all copies or substantial portions of the
     13  * Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
     21  * IN THE SOFTWARE.
     22  *
     23  * Authors:
     24  *    Jason Ekstrand (jason (at) jlekstrand.net)
     25  */
     26 
     27 #include <math.h>
     28 #include "main/core.h"
     29 #include "util/rounding.h" /* for _mesa_roundeven */
     30 #include "util/half_float.h"
     31 #include "nir_constant_expressions.h"
     32 
     33 /**
     34  * Evaluate one component of packSnorm4x8.
     35  */
     36 static uint8_t
     37 pack_snorm_1x8(float x)
     38 {
     39     /* From section 8.4 of the GLSL 4.30 spec:
     40      *
     41      *    packSnorm4x8
     42      *    ------------
     43      *    The conversion for component c of v to fixed point is done as
     44      *    follows:
     45      *
     46      *      packSnorm4x8: round(clamp(c, -1, +1) * 127.0)
     47      *
     48      * We must first cast the float to an int, because casting a negative
     49      * float to a uint is undefined.
     50      */
     51    return (uint8_t) (int)
     52           _mesa_roundevenf(CLAMP(x, -1.0f, +1.0f) * 127.0f);
     53 }
     54 
     55 /**
     56  * Evaluate one component of packSnorm2x16.
     57  */
     58 static uint16_t
     59 pack_snorm_1x16(float x)
     60 {
     61     /* From section 8.4 of the GLSL ES 3.00 spec:
     62      *
     63      *    packSnorm2x16
     64      *    -------------
     65      *    The conversion for component c of v to fixed point is done as
     66      *    follows:
     67      *
     68      *      packSnorm2x16: round(clamp(c, -1, +1) * 32767.0)
     69      *
     70      * We must first cast the float to an int, because casting a negative
     71      * float to a uint is undefined.
     72      */
     73    return (uint16_t) (int)
     74           _mesa_roundevenf(CLAMP(x, -1.0f, +1.0f) * 32767.0f);
     75 }
     76 
     77 /**
     78  * Evaluate one component of unpackSnorm4x8.
     79  */
     80 static float
     81 unpack_snorm_1x8(uint8_t u)
     82 {
     83     /* From section 8.4 of the GLSL 4.30 spec:
     84      *
     85      *    unpackSnorm4x8
     86      *    --------------
     87      *    The conversion for unpacked fixed-point value f to floating point is
     88      *    done as follows:
     89      *
     90      *       unpackSnorm4x8: clamp(f / 127.0, -1, +1)
     91      */
     92    return CLAMP((int8_t) u / 127.0f, -1.0f, +1.0f);
     93 }
     94 
     95 /**
     96  * Evaluate one component of unpackSnorm2x16.
     97  */
     98 static float
     99 unpack_snorm_1x16(uint16_t u)
    100 {
    101     /* From section 8.4 of the GLSL ES 3.00 spec:
    102      *
    103      *    unpackSnorm2x16
    104      *    ---------------
    105      *    The conversion for unpacked fixed-point value f to floating point is
    106      *    done as follows:
    107      *
    108      *       unpackSnorm2x16: clamp(f / 32767.0, -1, +1)
    109      */
    110    return CLAMP((int16_t) u / 32767.0f, -1.0f, +1.0f);
    111 }
    112 
    113 /**
    114  * Evaluate one component packUnorm4x8.
    115  */
    116 static uint8_t
    117 pack_unorm_1x8(float x)
    118 {
    119     /* From section 8.4 of the GLSL 4.30 spec:
    120      *
    121      *    packUnorm4x8
    122      *    ------------
    123      *    The conversion for component c of v to fixed point is done as
    124      *    follows:
    125      *
    126      *       packUnorm4x8: round(clamp(c, 0, +1) * 255.0)
    127      */
    128    return (uint8_t) (int)
    129           _mesa_roundevenf(CLAMP(x, 0.0f, 1.0f) * 255.0f);
    130 }
    131 
    132 /**
    133  * Evaluate one component packUnorm2x16.
    134  */
    135 static uint16_t
    136 pack_unorm_1x16(float x)
    137 {
    138     /* From section 8.4 of the GLSL ES 3.00 spec:
    139      *
    140      *    packUnorm2x16
    141      *    -------------
    142      *    The conversion for component c of v to fixed point is done as
    143      *    follows:
    144      *
    145      *       packUnorm2x16: round(clamp(c, 0, +1) * 65535.0)
    146      */
    147    return (uint16_t) (int)
    148           _mesa_roundevenf(CLAMP(x, 0.0f, 1.0f) * 65535.0f);
    149 }
    150 
    151 /**
    152  * Evaluate one component of unpackUnorm4x8.
    153  */
    154 static float
    155 unpack_unorm_1x8(uint8_t u)
    156 {
    157     /* From section 8.4 of the GLSL 4.30 spec:
    158      *
    159      *    unpackUnorm4x8
    160      *    --------------
    161      *    The conversion for unpacked fixed-point value f to floating point is
    162      *    done as follows:
    163      *
    164      *       unpackUnorm4x8: f / 255.0
    165      */
    166    return (float) u / 255.0f;
    167 }
    168 
    169 /**
    170  * Evaluate one component of unpackUnorm2x16.
    171  */
    172 static float
    173 unpack_unorm_1x16(uint16_t u)
    174 {
    175     /* From section 8.4 of the GLSL ES 3.00 spec:
    176      *
    177      *    unpackUnorm2x16
    178      *    ---------------
    179      *    The conversion for unpacked fixed-point value f to floating point is
    180      *    done as follows:
    181      *
    182      *       unpackUnorm2x16: f / 65535.0
    183      */
    184    return (float) u / 65535.0f;
    185 }
    186 
    187 /**
    188  * Evaluate one component of packHalf2x16.
    189  */
    190 static uint16_t
    191 pack_half_1x16(float x)
    192 {
    193    return _mesa_float_to_half(x);
    194 }
    195 
    196 /**
    197  * Evaluate one component of unpackHalf2x16.
    198  */
    199 static float
    200 unpack_half_1x16(uint16_t u)
    201 {
    202    return _mesa_half_to_float(u);
    203 }
    204 
    205 /* Some typed vector structures to make things like src0.y work */
    206 typedef float float32_t;
    207 typedef double float64_t;
    208 typedef bool bool32_t;
    209 struct float32_vec {
    210    float32_t x;
    211    float32_t y;
    212    float32_t z;
    213    float32_t w;
    214 };
    215 struct float64_vec {
    216    float64_t x;
    217    float64_t y;
    218    float64_t z;
    219    float64_t w;
    220 };
    221 struct int32_vec {
    222    int32_t x;
    223    int32_t y;
    224    int32_t z;
    225    int32_t w;
    226 };
    227 struct int64_vec {
    228    int64_t x;
    229    int64_t y;
    230    int64_t z;
    231    int64_t w;
    232 };
    233 struct uint32_vec {
    234    uint32_t x;
    235    uint32_t y;
    236    uint32_t z;
    237    uint32_t w;
    238 };
    239 struct uint64_vec {
    240    uint64_t x;
    241    uint64_t y;
    242    uint64_t z;
    243    uint64_t w;
    244 };
    245 
    246 struct bool32_vec {
    247     bool x;
    248     bool y;
    249     bool z;
    250     bool w;
    251 };
    252 
    253 static nir_const_value
    254 evaluate_b2f(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    255                  MAYBE_UNUSED nir_const_value *_src)
    256 {
    257    nir_const_value _dst_val = { {0, } };
    258 
    259    switch (bit_size) {
    260    case 32: {
    261 
    262 
    263 
    264          for (unsigned _i = 0; _i < num_components; _i++) {
    265                   const bool src0 = _src[0].u32[_i] != 0;
    266 
    267                float32_t dst = src0 ? 1.0f : 0.0f;
    268 
    269                _dst_val.f32[_i] = dst;
    270          }
    271 
    272       break;
    273    }
    274    case 64: {
    275 
    276 
    277 
    278          for (unsigned _i = 0; _i < num_components; _i++) {
    279                   const bool src0 = _src[0].u32[_i] != 0;
    280 
    281                float32_t dst = src0 ? 1.0f : 0.0f;
    282 
    283                _dst_val.f32[_i] = dst;
    284          }
    285 
    286       break;
    287    }
    288 
    289    default:
    290       unreachable("unknown bit width");
    291    }
    292 
    293    return _dst_val;
    294 }
    295 static nir_const_value
    296 evaluate_b2i(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    297                  MAYBE_UNUSED nir_const_value *_src)
    298 {
    299    nir_const_value _dst_val = { {0, } };
    300 
    301    switch (bit_size) {
    302    case 32: {
    303 
    304 
    305 
    306          for (unsigned _i = 0; _i < num_components; _i++) {
    307                   const bool src0 = _src[0].u32[_i] != 0;
    308 
    309                int32_t dst = src0 ? 1 : 0;
    310 
    311                _dst_val.i32[_i] = dst;
    312          }
    313 
    314       break;
    315    }
    316    case 64: {
    317 
    318 
    319 
    320          for (unsigned _i = 0; _i < num_components; _i++) {
    321                   const bool src0 = _src[0].u32[_i] != 0;
    322 
    323                int32_t dst = src0 ? 1 : 0;
    324 
    325                _dst_val.i32[_i] = dst;
    326          }
    327 
    328       break;
    329    }
    330 
    331    default:
    332       unreachable("unknown bit width");
    333    }
    334 
    335    return _dst_val;
    336 }
    337 static nir_const_value
    338 evaluate_ball_fequal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    339                  MAYBE_UNUSED nir_const_value *_src)
    340 {
    341    nir_const_value _dst_val = { {0, } };
    342 
    343    switch (bit_size) {
    344    case 32: {
    345 
    346 
    347 
    348          const struct float32_vec src0 = {
    349                _src[0].f32[0],
    350                _src[0].f32[1],
    351             0,
    352             0,
    353          };
    354 
    355          const struct float32_vec src1 = {
    356                _src[1].f32[0],
    357                _src[1].f32[1],
    358             0,
    359             0,
    360          };
    361 
    362          struct bool32_vec dst;
    363 
    364             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
    365 
    366                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    367 
    368       break;
    369    }
    370    case 64: {
    371 
    372 
    373 
    374          const struct float64_vec src0 = {
    375                _src[0].f64[0],
    376                _src[0].f64[1],
    377             0,
    378             0,
    379          };
    380 
    381          const struct float64_vec src1 = {
    382                _src[1].f64[0],
    383                _src[1].f64[1],
    384             0,
    385             0,
    386          };
    387 
    388          struct bool32_vec dst;
    389 
    390             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
    391 
    392                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    393 
    394       break;
    395    }
    396 
    397    default:
    398       unreachable("unknown bit width");
    399    }
    400 
    401    return _dst_val;
    402 }
    403 static nir_const_value
    404 evaluate_ball_fequal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    405                  MAYBE_UNUSED nir_const_value *_src)
    406 {
    407    nir_const_value _dst_val = { {0, } };
    408 
    409    switch (bit_size) {
    410    case 32: {
    411 
    412 
    413 
    414          const struct float32_vec src0 = {
    415                _src[0].f32[0],
    416                _src[0].f32[1],
    417                _src[0].f32[2],
    418             0,
    419          };
    420 
    421          const struct float32_vec src1 = {
    422                _src[1].f32[0],
    423                _src[1].f32[1],
    424                _src[1].f32[2],
    425             0,
    426          };
    427 
    428          struct bool32_vec dst;
    429 
    430             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
    431 
    432                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    433 
    434       break;
    435    }
    436    case 64: {
    437 
    438 
    439 
    440          const struct float64_vec src0 = {
    441                _src[0].f64[0],
    442                _src[0].f64[1],
    443                _src[0].f64[2],
    444             0,
    445          };
    446 
    447          const struct float64_vec src1 = {
    448                _src[1].f64[0],
    449                _src[1].f64[1],
    450                _src[1].f64[2],
    451             0,
    452          };
    453 
    454          struct bool32_vec dst;
    455 
    456             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
    457 
    458                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    459 
    460       break;
    461    }
    462 
    463    default:
    464       unreachable("unknown bit width");
    465    }
    466 
    467    return _dst_val;
    468 }
    469 static nir_const_value
    470 evaluate_ball_fequal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    471                  MAYBE_UNUSED nir_const_value *_src)
    472 {
    473    nir_const_value _dst_val = { {0, } };
    474 
    475    switch (bit_size) {
    476    case 32: {
    477 
    478 
    479 
    480          const struct float32_vec src0 = {
    481                _src[0].f32[0],
    482                _src[0].f32[1],
    483                _src[0].f32[2],
    484                _src[0].f32[3],
    485          };
    486 
    487          const struct float32_vec src1 = {
    488                _src[1].f32[0],
    489                _src[1].f32[1],
    490                _src[1].f32[2],
    491                _src[1].f32[3],
    492          };
    493 
    494          struct bool32_vec dst;
    495 
    496             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
    497 
    498                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    499 
    500       break;
    501    }
    502    case 64: {
    503 
    504 
    505 
    506          const struct float64_vec src0 = {
    507                _src[0].f64[0],
    508                _src[0].f64[1],
    509                _src[0].f64[2],
    510                _src[0].f64[3],
    511          };
    512 
    513          const struct float64_vec src1 = {
    514                _src[1].f64[0],
    515                _src[1].f64[1],
    516                _src[1].f64[2],
    517                _src[1].f64[3],
    518          };
    519 
    520          struct bool32_vec dst;
    521 
    522             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
    523 
    524                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    525 
    526       break;
    527    }
    528 
    529    default:
    530       unreachable("unknown bit width");
    531    }
    532 
    533    return _dst_val;
    534 }
    535 static nir_const_value
    536 evaluate_ball_iequal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    537                  MAYBE_UNUSED nir_const_value *_src)
    538 {
    539    nir_const_value _dst_val = { {0, } };
    540 
    541    switch (bit_size) {
    542    case 32: {
    543 
    544 
    545 
    546          const struct int32_vec src0 = {
    547                _src[0].i32[0],
    548                _src[0].i32[1],
    549             0,
    550             0,
    551          };
    552 
    553          const struct int32_vec src1 = {
    554                _src[1].i32[0],
    555                _src[1].i32[1],
    556             0,
    557             0,
    558          };
    559 
    560          struct bool32_vec dst;
    561 
    562             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
    563 
    564                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    565 
    566       break;
    567    }
    568    case 64: {
    569 
    570 
    571 
    572          const struct int64_vec src0 = {
    573                _src[0].i64[0],
    574                _src[0].i64[1],
    575             0,
    576             0,
    577          };
    578 
    579          const struct int64_vec src1 = {
    580                _src[1].i64[0],
    581                _src[1].i64[1],
    582             0,
    583             0,
    584          };
    585 
    586          struct bool32_vec dst;
    587 
    588             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y));
    589 
    590                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    591 
    592       break;
    593    }
    594 
    595    default:
    596       unreachable("unknown bit width");
    597    }
    598 
    599    return _dst_val;
    600 }
    601 static nir_const_value
    602 evaluate_ball_iequal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    603                  MAYBE_UNUSED nir_const_value *_src)
    604 {
    605    nir_const_value _dst_val = { {0, } };
    606 
    607    switch (bit_size) {
    608    case 32: {
    609 
    610 
    611 
    612          const struct int32_vec src0 = {
    613                _src[0].i32[0],
    614                _src[0].i32[1],
    615                _src[0].i32[2],
    616             0,
    617          };
    618 
    619          const struct int32_vec src1 = {
    620                _src[1].i32[0],
    621                _src[1].i32[1],
    622                _src[1].i32[2],
    623             0,
    624          };
    625 
    626          struct bool32_vec dst;
    627 
    628             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
    629 
    630                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    631 
    632       break;
    633    }
    634    case 64: {
    635 
    636 
    637 
    638          const struct int64_vec src0 = {
    639                _src[0].i64[0],
    640                _src[0].i64[1],
    641                _src[0].i64[2],
    642             0,
    643          };
    644 
    645          const struct int64_vec src1 = {
    646                _src[1].i64[0],
    647                _src[1].i64[1],
    648                _src[1].i64[2],
    649             0,
    650          };
    651 
    652          struct bool32_vec dst;
    653 
    654             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z));
    655 
    656                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    657 
    658       break;
    659    }
    660 
    661    default:
    662       unreachable("unknown bit width");
    663    }
    664 
    665    return _dst_val;
    666 }
    667 static nir_const_value
    668 evaluate_ball_iequal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    669                  MAYBE_UNUSED nir_const_value *_src)
    670 {
    671    nir_const_value _dst_val = { {0, } };
    672 
    673    switch (bit_size) {
    674    case 32: {
    675 
    676 
    677 
    678          const struct int32_vec src0 = {
    679                _src[0].i32[0],
    680                _src[0].i32[1],
    681                _src[0].i32[2],
    682                _src[0].i32[3],
    683          };
    684 
    685          const struct int32_vec src1 = {
    686                _src[1].i32[0],
    687                _src[1].i32[1],
    688                _src[1].i32[2],
    689                _src[1].i32[3],
    690          };
    691 
    692          struct bool32_vec dst;
    693 
    694             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
    695 
    696                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    697 
    698       break;
    699    }
    700    case 64: {
    701 
    702 
    703 
    704          const struct int64_vec src0 = {
    705                _src[0].i64[0],
    706                _src[0].i64[1],
    707                _src[0].i64[2],
    708                _src[0].i64[3],
    709          };
    710 
    711          const struct int64_vec src1 = {
    712                _src[1].i64[0],
    713                _src[1].i64[1],
    714                _src[1].i64[2],
    715                _src[1].i64[3],
    716          };
    717 
    718          struct bool32_vec dst;
    719 
    720             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w));
    721 
    722                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    723 
    724       break;
    725    }
    726 
    727    default:
    728       unreachable("unknown bit width");
    729    }
    730 
    731    return _dst_val;
    732 }
    733 static nir_const_value
    734 evaluate_bany_fnequal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    735                  MAYBE_UNUSED nir_const_value *_src)
    736 {
    737    nir_const_value _dst_val = { {0, } };
    738 
    739    switch (bit_size) {
    740    case 32: {
    741 
    742 
    743 
    744          const struct float32_vec src0 = {
    745                _src[0].f32[0],
    746                _src[0].f32[1],
    747             0,
    748             0,
    749          };
    750 
    751          const struct float32_vec src1 = {
    752                _src[1].f32[0],
    753                _src[1].f32[1],
    754             0,
    755             0,
    756          };
    757 
    758          struct bool32_vec dst;
    759 
    760             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
    761 
    762                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    763 
    764       break;
    765    }
    766    case 64: {
    767 
    768 
    769 
    770          const struct float64_vec src0 = {
    771                _src[0].f64[0],
    772                _src[0].f64[1],
    773             0,
    774             0,
    775          };
    776 
    777          const struct float64_vec src1 = {
    778                _src[1].f64[0],
    779                _src[1].f64[1],
    780             0,
    781             0,
    782          };
    783 
    784          struct bool32_vec dst;
    785 
    786             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
    787 
    788                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    789 
    790       break;
    791    }
    792 
    793    default:
    794       unreachable("unknown bit width");
    795    }
    796 
    797    return _dst_val;
    798 }
    799 static nir_const_value
    800 evaluate_bany_fnequal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    801                  MAYBE_UNUSED nir_const_value *_src)
    802 {
    803    nir_const_value _dst_val = { {0, } };
    804 
    805    switch (bit_size) {
    806    case 32: {
    807 
    808 
    809 
    810          const struct float32_vec src0 = {
    811                _src[0].f32[0],
    812                _src[0].f32[1],
    813                _src[0].f32[2],
    814             0,
    815          };
    816 
    817          const struct float32_vec src1 = {
    818                _src[1].f32[0],
    819                _src[1].f32[1],
    820                _src[1].f32[2],
    821             0,
    822          };
    823 
    824          struct bool32_vec dst;
    825 
    826             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
    827 
    828                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    829 
    830       break;
    831    }
    832    case 64: {
    833 
    834 
    835 
    836          const struct float64_vec src0 = {
    837                _src[0].f64[0],
    838                _src[0].f64[1],
    839                _src[0].f64[2],
    840             0,
    841          };
    842 
    843          const struct float64_vec src1 = {
    844                _src[1].f64[0],
    845                _src[1].f64[1],
    846                _src[1].f64[2],
    847             0,
    848          };
    849 
    850          struct bool32_vec dst;
    851 
    852             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
    853 
    854                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    855 
    856       break;
    857    }
    858 
    859    default:
    860       unreachable("unknown bit width");
    861    }
    862 
    863    return _dst_val;
    864 }
    865 static nir_const_value
    866 evaluate_bany_fnequal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    867                  MAYBE_UNUSED nir_const_value *_src)
    868 {
    869    nir_const_value _dst_val = { {0, } };
    870 
    871    switch (bit_size) {
    872    case 32: {
    873 
    874 
    875 
    876          const struct float32_vec src0 = {
    877                _src[0].f32[0],
    878                _src[0].f32[1],
    879                _src[0].f32[2],
    880                _src[0].f32[3],
    881          };
    882 
    883          const struct float32_vec src1 = {
    884                _src[1].f32[0],
    885                _src[1].f32[1],
    886                _src[1].f32[2],
    887                _src[1].f32[3],
    888          };
    889 
    890          struct bool32_vec dst;
    891 
    892             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
    893 
    894                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    895 
    896       break;
    897    }
    898    case 64: {
    899 
    900 
    901 
    902          const struct float64_vec src0 = {
    903                _src[0].f64[0],
    904                _src[0].f64[1],
    905                _src[0].f64[2],
    906                _src[0].f64[3],
    907          };
    908 
    909          const struct float64_vec src1 = {
    910                _src[1].f64[0],
    911                _src[1].f64[1],
    912                _src[1].f64[2],
    913                _src[1].f64[3],
    914          };
    915 
    916          struct bool32_vec dst;
    917 
    918             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
    919 
    920                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    921 
    922       break;
    923    }
    924 
    925    default:
    926       unreachable("unknown bit width");
    927    }
    928 
    929    return _dst_val;
    930 }
    931 static nir_const_value
    932 evaluate_bany_inequal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    933                  MAYBE_UNUSED nir_const_value *_src)
    934 {
    935    nir_const_value _dst_val = { {0, } };
    936 
    937    switch (bit_size) {
    938    case 32: {
    939 
    940 
    941 
    942          const struct int32_vec src0 = {
    943                _src[0].i32[0],
    944                _src[0].i32[1],
    945             0,
    946             0,
    947          };
    948 
    949          const struct int32_vec src1 = {
    950                _src[1].i32[0],
    951                _src[1].i32[1],
    952             0,
    953             0,
    954          };
    955 
    956          struct bool32_vec dst;
    957 
    958             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
    959 
    960                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    961 
    962       break;
    963    }
    964    case 64: {
    965 
    966 
    967 
    968          const struct int64_vec src0 = {
    969                _src[0].i64[0],
    970                _src[0].i64[1],
    971             0,
    972             0,
    973          };
    974 
    975          const struct int64_vec src1 = {
    976                _src[1].i64[0],
    977                _src[1].i64[1],
    978             0,
    979             0,
    980          };
    981 
    982          struct bool32_vec dst;
    983 
    984             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y));
    985 
    986                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
    987 
    988       break;
    989    }
    990 
    991    default:
    992       unreachable("unknown bit width");
    993    }
    994 
    995    return _dst_val;
    996 }
    997 static nir_const_value
    998 evaluate_bany_inequal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
    999                  MAYBE_UNUSED nir_const_value *_src)
   1000 {
   1001    nir_const_value _dst_val = { {0, } };
   1002 
   1003    switch (bit_size) {
   1004    case 32: {
   1005 
   1006 
   1007 
   1008          const struct int32_vec src0 = {
   1009                _src[0].i32[0],
   1010                _src[0].i32[1],
   1011                _src[0].i32[2],
   1012             0,
   1013          };
   1014 
   1015          const struct int32_vec src1 = {
   1016                _src[1].i32[0],
   1017                _src[1].i32[1],
   1018                _src[1].i32[2],
   1019             0,
   1020          };
   1021 
   1022          struct bool32_vec dst;
   1023 
   1024             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
   1025 
   1026                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
   1027 
   1028       break;
   1029    }
   1030    case 64: {
   1031 
   1032 
   1033 
   1034          const struct int64_vec src0 = {
   1035                _src[0].i64[0],
   1036                _src[0].i64[1],
   1037                _src[0].i64[2],
   1038             0,
   1039          };
   1040 
   1041          const struct int64_vec src1 = {
   1042                _src[1].i64[0],
   1043                _src[1].i64[1],
   1044                _src[1].i64[2],
   1045             0,
   1046          };
   1047 
   1048          struct bool32_vec dst;
   1049 
   1050             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z));
   1051 
   1052                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
   1053 
   1054       break;
   1055    }
   1056 
   1057    default:
   1058       unreachable("unknown bit width");
   1059    }
   1060 
   1061    return _dst_val;
   1062 }
   1063 static nir_const_value
   1064 evaluate_bany_inequal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1065                  MAYBE_UNUSED nir_const_value *_src)
   1066 {
   1067    nir_const_value _dst_val = { {0, } };
   1068 
   1069    switch (bit_size) {
   1070    case 32: {
   1071 
   1072 
   1073 
   1074          const struct int32_vec src0 = {
   1075                _src[0].i32[0],
   1076                _src[0].i32[1],
   1077                _src[0].i32[2],
   1078                _src[0].i32[3],
   1079          };
   1080 
   1081          const struct int32_vec src1 = {
   1082                _src[1].i32[0],
   1083                _src[1].i32[1],
   1084                _src[1].i32[2],
   1085                _src[1].i32[3],
   1086          };
   1087 
   1088          struct bool32_vec dst;
   1089 
   1090             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
   1091 
   1092                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
   1093 
   1094       break;
   1095    }
   1096    case 64: {
   1097 
   1098 
   1099 
   1100          const struct int64_vec src0 = {
   1101                _src[0].i64[0],
   1102                _src[0].i64[1],
   1103                _src[0].i64[2],
   1104                _src[0].i64[3],
   1105          };
   1106 
   1107          const struct int64_vec src1 = {
   1108                _src[1].i64[0],
   1109                _src[1].i64[1],
   1110                _src[1].i64[2],
   1111                _src[1].i64[3],
   1112          };
   1113 
   1114          struct bool32_vec dst;
   1115 
   1116             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w));
   1117 
   1118                _dst_val.u32[0] = dst.x ? NIR_TRUE : NIR_FALSE;
   1119 
   1120       break;
   1121    }
   1122 
   1123    default:
   1124       unreachable("unknown bit width");
   1125    }
   1126 
   1127    return _dst_val;
   1128 }
   1129 static nir_const_value
   1130 evaluate_bcsel(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1131                  MAYBE_UNUSED nir_const_value *_src)
   1132 {
   1133    nir_const_value _dst_val = { {0, } };
   1134 
   1135    switch (bit_size) {
   1136    case 32: {
   1137 
   1138 
   1139 
   1140          for (unsigned _i = 0; _i < num_components; _i++) {
   1141                   const bool src0 = _src[0].u32[_i] != 0;
   1142                   const uint32_t src1 =
   1143                      _src[1].u32[_i];
   1144                   const uint32_t src2 =
   1145                      _src[2].u32[_i];
   1146 
   1147                uint32_t dst = src0 ? src1 : src2;
   1148 
   1149                _dst_val.u32[_i] = dst;
   1150          }
   1151 
   1152       break;
   1153    }
   1154    case 64: {
   1155 
   1156 
   1157 
   1158          for (unsigned _i = 0; _i < num_components; _i++) {
   1159                   const bool src0 = _src[0].u32[_i] != 0;
   1160                   const uint64_t src1 =
   1161                      _src[1].u64[_i];
   1162                   const uint64_t src2 =
   1163                      _src[2].u64[_i];
   1164 
   1165                uint64_t dst = src0 ? src1 : src2;
   1166 
   1167                _dst_val.u64[_i] = dst;
   1168          }
   1169 
   1170       break;
   1171    }
   1172 
   1173    default:
   1174       unreachable("unknown bit width");
   1175    }
   1176 
   1177    return _dst_val;
   1178 }
   1179 static nir_const_value
   1180 evaluate_bfi(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1181                  MAYBE_UNUSED nir_const_value *_src)
   1182 {
   1183    nir_const_value _dst_val = { {0, } };
   1184 
   1185    switch (bit_size) {
   1186    case 32: {
   1187 
   1188 
   1189 
   1190          for (unsigned _i = 0; _i < num_components; _i++) {
   1191                   const uint32_t src0 =
   1192                      _src[0].u32[_i];
   1193                   const uint32_t src1 =
   1194                      _src[1].u32[_i];
   1195                   const uint32_t src2 =
   1196                      _src[2].u32[_i];
   1197 
   1198                uint32_t dst;
   1199 
   1200 
   1201 unsigned mask = src0, insert = src1, base = src2;
   1202 if (mask == 0) {
   1203    dst = base;
   1204 } else {
   1205    unsigned tmp = mask;
   1206    while (!(tmp & 1)) {
   1207       tmp >>= 1;
   1208       insert <<= 1;
   1209    }
   1210    dst = (base & ~mask) | (insert & mask);
   1211 }
   1212 
   1213 
   1214                _dst_val.u32[_i] = dst;
   1215          }
   1216 
   1217       break;
   1218    }
   1219    case 64: {
   1220 
   1221 
   1222 
   1223          for (unsigned _i = 0; _i < num_components; _i++) {
   1224                   const uint32_t src0 =
   1225                      _src[0].u32[_i];
   1226                   const uint32_t src1 =
   1227                      _src[1].u32[_i];
   1228                   const uint32_t src2 =
   1229                      _src[2].u32[_i];
   1230 
   1231                uint32_t dst;
   1232 
   1233 
   1234 unsigned mask = src0, insert = src1, base = src2;
   1235 if (mask == 0) {
   1236    dst = base;
   1237 } else {
   1238    unsigned tmp = mask;
   1239    while (!(tmp & 1)) {
   1240       tmp >>= 1;
   1241       insert <<= 1;
   1242    }
   1243    dst = (base & ~mask) | (insert & mask);
   1244 }
   1245 
   1246 
   1247                _dst_val.u32[_i] = dst;
   1248          }
   1249 
   1250       break;
   1251    }
   1252 
   1253    default:
   1254       unreachable("unknown bit width");
   1255    }
   1256 
   1257    return _dst_val;
   1258 }
   1259 static nir_const_value
   1260 evaluate_bfm(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1261                  MAYBE_UNUSED nir_const_value *_src)
   1262 {
   1263    nir_const_value _dst_val = { {0, } };
   1264 
   1265    switch (bit_size) {
   1266    case 32: {
   1267 
   1268 
   1269 
   1270          for (unsigned _i = 0; _i < num_components; _i++) {
   1271                   const int32_t src0 =
   1272                      _src[0].i32[_i];
   1273                   const int32_t src1 =
   1274                      _src[1].i32[_i];
   1275 
   1276                uint32_t dst;
   1277 
   1278 
   1279 int bits = src0, offset = src1;
   1280 if (offset < 0 || bits < 0 || offset > 31 || bits > 31 || offset + bits > 32)
   1281    dst = 0; /* undefined */
   1282 else
   1283    dst = ((1u << bits) - 1) << offset;
   1284 
   1285 
   1286                _dst_val.u32[_i] = dst;
   1287          }
   1288 
   1289       break;
   1290    }
   1291    case 64: {
   1292 
   1293 
   1294 
   1295          for (unsigned _i = 0; _i < num_components; _i++) {
   1296                   const int32_t src0 =
   1297                      _src[0].i32[_i];
   1298                   const int32_t src1 =
   1299                      _src[1].i32[_i];
   1300 
   1301                uint32_t dst;
   1302 
   1303 
   1304 int bits = src0, offset = src1;
   1305 if (offset < 0 || bits < 0 || offset > 31 || bits > 31 || offset + bits > 32)
   1306    dst = 0; /* undefined */
   1307 else
   1308    dst = ((1u << bits) - 1) << offset;
   1309 
   1310 
   1311                _dst_val.u32[_i] = dst;
   1312          }
   1313 
   1314       break;
   1315    }
   1316 
   1317    default:
   1318       unreachable("unknown bit width");
   1319    }
   1320 
   1321    return _dst_val;
   1322 }
   1323 static nir_const_value
   1324 evaluate_bit_count(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1325                  MAYBE_UNUSED nir_const_value *_src)
   1326 {
   1327    nir_const_value _dst_val = { {0, } };
   1328 
   1329    switch (bit_size) {
   1330    case 32: {
   1331 
   1332 
   1333 
   1334          for (unsigned _i = 0; _i < num_components; _i++) {
   1335                   const uint32_t src0 =
   1336                      _src[0].u32[_i];
   1337 
   1338                uint32_t dst;
   1339 
   1340 
   1341 dst = 0;
   1342 for (unsigned bit = 0; bit < 32; bit++) {
   1343    if ((src0 >> bit) & 1)
   1344       dst++;
   1345 }
   1346 
   1347 
   1348                _dst_val.u32[_i] = dst;
   1349          }
   1350 
   1351       break;
   1352    }
   1353    case 64: {
   1354 
   1355 
   1356 
   1357          for (unsigned _i = 0; _i < num_components; _i++) {
   1358                   const uint32_t src0 =
   1359                      _src[0].u32[_i];
   1360 
   1361                uint32_t dst;
   1362 
   1363 
   1364 dst = 0;
   1365 for (unsigned bit = 0; bit < 32; bit++) {
   1366    if ((src0 >> bit) & 1)
   1367       dst++;
   1368 }
   1369 
   1370 
   1371                _dst_val.u32[_i] = dst;
   1372          }
   1373 
   1374       break;
   1375    }
   1376 
   1377    default:
   1378       unreachable("unknown bit width");
   1379    }
   1380 
   1381    return _dst_val;
   1382 }
   1383 static nir_const_value
   1384 evaluate_bitfield_insert(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1385                  MAYBE_UNUSED nir_const_value *_src)
   1386 {
   1387    nir_const_value _dst_val = { {0, } };
   1388 
   1389    switch (bit_size) {
   1390    case 32: {
   1391 
   1392 
   1393 
   1394          for (unsigned _i = 0; _i < num_components; _i++) {
   1395                   const uint32_t src0 =
   1396                      _src[0].u32[_i];
   1397                   const uint32_t src1 =
   1398                      _src[1].u32[_i];
   1399                   const int32_t src2 =
   1400                      _src[2].i32[_i];
   1401                   const int32_t src3 =
   1402                      _src[3].i32[_i];
   1403 
   1404                uint32_t dst;
   1405 
   1406 
   1407 unsigned base = src0, insert = src1;
   1408 int offset = src2, bits = src3;
   1409 if (bits == 0) {
   1410    dst = 0;
   1411 } else if (offset < 0 || bits < 0 || bits + offset > 32) {
   1412    dst = 0;
   1413 } else {
   1414    unsigned mask = ((1ull << bits) - 1) << offset;
   1415    dst = (base & ~mask) | ((insert << bits) & mask);
   1416 }
   1417 
   1418 
   1419                _dst_val.u32[_i] = dst;
   1420          }
   1421 
   1422       break;
   1423    }
   1424    case 64: {
   1425 
   1426 
   1427 
   1428          for (unsigned _i = 0; _i < num_components; _i++) {
   1429                   const uint32_t src0 =
   1430                      _src[0].u32[_i];
   1431                   const uint32_t src1 =
   1432                      _src[1].u32[_i];
   1433                   const int32_t src2 =
   1434                      _src[2].i32[_i];
   1435                   const int32_t src3 =
   1436                      _src[3].i32[_i];
   1437 
   1438                uint32_t dst;
   1439 
   1440 
   1441 unsigned base = src0, insert = src1;
   1442 int offset = src2, bits = src3;
   1443 if (bits == 0) {
   1444    dst = 0;
   1445 } else if (offset < 0 || bits < 0 || bits + offset > 32) {
   1446    dst = 0;
   1447 } else {
   1448    unsigned mask = ((1ull << bits) - 1) << offset;
   1449    dst = (base & ~mask) | ((insert << bits) & mask);
   1450 }
   1451 
   1452 
   1453                _dst_val.u32[_i] = dst;
   1454          }
   1455 
   1456       break;
   1457    }
   1458 
   1459    default:
   1460       unreachable("unknown bit width");
   1461    }
   1462 
   1463    return _dst_val;
   1464 }
   1465 static nir_const_value
   1466 evaluate_bitfield_reverse(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1467                  MAYBE_UNUSED nir_const_value *_src)
   1468 {
   1469    nir_const_value _dst_val = { {0, } };
   1470 
   1471    switch (bit_size) {
   1472    case 32: {
   1473 
   1474 
   1475 
   1476          for (unsigned _i = 0; _i < num_components; _i++) {
   1477                   const uint32_t src0 =
   1478                      _src[0].u32[_i];
   1479 
   1480                uint32_t dst;
   1481 
   1482 
   1483 /* we're not winning any awards for speed here, but that's ok */
   1484 dst = 0;
   1485 for (unsigned bit = 0; bit < 32; bit++)
   1486    dst |= ((src0 >> bit) & 1) << (31 - bit);
   1487 
   1488 
   1489                _dst_val.u32[_i] = dst;
   1490          }
   1491 
   1492       break;
   1493    }
   1494    case 64: {
   1495 
   1496 
   1497 
   1498          for (unsigned _i = 0; _i < num_components; _i++) {
   1499                   const uint32_t src0 =
   1500                      _src[0].u32[_i];
   1501 
   1502                uint32_t dst;
   1503 
   1504 
   1505 /* we're not winning any awards for speed here, but that's ok */
   1506 dst = 0;
   1507 for (unsigned bit = 0; bit < 32; bit++)
   1508    dst |= ((src0 >> bit) & 1) << (31 - bit);
   1509 
   1510 
   1511                _dst_val.u32[_i] = dst;
   1512          }
   1513 
   1514       break;
   1515    }
   1516 
   1517    default:
   1518       unreachable("unknown bit width");
   1519    }
   1520 
   1521    return _dst_val;
   1522 }
   1523 static nir_const_value
   1524 evaluate_d2b(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1525                  MAYBE_UNUSED nir_const_value *_src)
   1526 {
   1527    nir_const_value _dst_val = { {0, } };
   1528 
   1529    switch (bit_size) {
   1530    case 32: {
   1531 
   1532 
   1533 
   1534          for (unsigned _i = 0; _i < num_components; _i++) {
   1535                   const float64_t src0 =
   1536                      _src[0].f64[_i];
   1537 
   1538                bool32_t dst = src0 != 0.0;
   1539 
   1540                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   1541          }
   1542 
   1543       break;
   1544    }
   1545    case 64: {
   1546 
   1547 
   1548 
   1549          for (unsigned _i = 0; _i < num_components; _i++) {
   1550                   const float64_t src0 =
   1551                      _src[0].f64[_i];
   1552 
   1553                bool32_t dst = src0 != 0.0;
   1554 
   1555                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   1556          }
   1557 
   1558       break;
   1559    }
   1560 
   1561    default:
   1562       unreachable("unknown bit width");
   1563    }
   1564 
   1565    return _dst_val;
   1566 }
   1567 static nir_const_value
   1568 evaluate_d2f(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1569                  MAYBE_UNUSED nir_const_value *_src)
   1570 {
   1571    nir_const_value _dst_val = { {0, } };
   1572 
   1573    switch (bit_size) {
   1574    case 32: {
   1575 
   1576 
   1577 
   1578          for (unsigned _i = 0; _i < num_components; _i++) {
   1579                   const float64_t src0 =
   1580                      _src[0].f64[_i];
   1581 
   1582                float32_t dst = src0;
   1583 
   1584                _dst_val.f32[_i] = dst;
   1585          }
   1586 
   1587       break;
   1588    }
   1589    case 64: {
   1590 
   1591 
   1592 
   1593          for (unsigned _i = 0; _i < num_components; _i++) {
   1594                   const float64_t src0 =
   1595                      _src[0].f64[_i];
   1596 
   1597                float32_t dst = src0;
   1598 
   1599                _dst_val.f32[_i] = dst;
   1600          }
   1601 
   1602       break;
   1603    }
   1604 
   1605    default:
   1606       unreachable("unknown bit width");
   1607    }
   1608 
   1609    return _dst_val;
   1610 }
   1611 static nir_const_value
   1612 evaluate_d2i(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1613                  MAYBE_UNUSED nir_const_value *_src)
   1614 {
   1615    nir_const_value _dst_val = { {0, } };
   1616 
   1617    switch (bit_size) {
   1618    case 32: {
   1619 
   1620 
   1621 
   1622          for (unsigned _i = 0; _i < num_components; _i++) {
   1623                   const float64_t src0 =
   1624                      _src[0].f64[_i];
   1625 
   1626                int32_t dst = src0;
   1627 
   1628                _dst_val.i32[_i] = dst;
   1629          }
   1630 
   1631       break;
   1632    }
   1633    case 64: {
   1634 
   1635 
   1636 
   1637          for (unsigned _i = 0; _i < num_components; _i++) {
   1638                   const float64_t src0 =
   1639                      _src[0].f64[_i];
   1640 
   1641                int32_t dst = src0;
   1642 
   1643                _dst_val.i32[_i] = dst;
   1644          }
   1645 
   1646       break;
   1647    }
   1648 
   1649    default:
   1650       unreachable("unknown bit width");
   1651    }
   1652 
   1653    return _dst_val;
   1654 }
   1655 static nir_const_value
   1656 evaluate_d2u(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1657                  MAYBE_UNUSED nir_const_value *_src)
   1658 {
   1659    nir_const_value _dst_val = { {0, } };
   1660 
   1661    switch (bit_size) {
   1662    case 32: {
   1663 
   1664 
   1665 
   1666          for (unsigned _i = 0; _i < num_components; _i++) {
   1667                   const float64_t src0 =
   1668                      _src[0].f64[_i];
   1669 
   1670                uint32_t dst = src0;
   1671 
   1672                _dst_val.u32[_i] = dst;
   1673          }
   1674 
   1675       break;
   1676    }
   1677    case 64: {
   1678 
   1679 
   1680 
   1681          for (unsigned _i = 0; _i < num_components; _i++) {
   1682                   const float64_t src0 =
   1683                      _src[0].f64[_i];
   1684 
   1685                uint32_t dst = src0;
   1686 
   1687                _dst_val.u32[_i] = dst;
   1688          }
   1689 
   1690       break;
   1691    }
   1692 
   1693    default:
   1694       unreachable("unknown bit width");
   1695    }
   1696 
   1697    return _dst_val;
   1698 }
   1699 static nir_const_value
   1700 evaluate_extract_i16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1701                  MAYBE_UNUSED nir_const_value *_src)
   1702 {
   1703    nir_const_value _dst_val = { {0, } };
   1704 
   1705    switch (bit_size) {
   1706    case 32: {
   1707 
   1708 
   1709 
   1710          for (unsigned _i = 0; _i < num_components; _i++) {
   1711                   const int32_t src0 =
   1712                      _src[0].i32[_i];
   1713                   const int32_t src1 =
   1714                      _src[1].i32[_i];
   1715 
   1716                int32_t dst = (int16_t)(src0 >> (src1 * 16));
   1717 
   1718                _dst_val.i32[_i] = dst;
   1719          }
   1720 
   1721       break;
   1722    }
   1723    case 64: {
   1724 
   1725 
   1726 
   1727          for (unsigned _i = 0; _i < num_components; _i++) {
   1728                   const int64_t src0 =
   1729                      _src[0].i64[_i];
   1730                   const int64_t src1 =
   1731                      _src[1].i64[_i];
   1732 
   1733                int64_t dst = (int16_t)(src0 >> (src1 * 16));
   1734 
   1735                _dst_val.i64[_i] = dst;
   1736          }
   1737 
   1738       break;
   1739    }
   1740 
   1741    default:
   1742       unreachable("unknown bit width");
   1743    }
   1744 
   1745    return _dst_val;
   1746 }
   1747 static nir_const_value
   1748 evaluate_extract_i8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1749                  MAYBE_UNUSED nir_const_value *_src)
   1750 {
   1751    nir_const_value _dst_val = { {0, } };
   1752 
   1753    switch (bit_size) {
   1754    case 32: {
   1755 
   1756 
   1757 
   1758          for (unsigned _i = 0; _i < num_components; _i++) {
   1759                   const int32_t src0 =
   1760                      _src[0].i32[_i];
   1761                   const int32_t src1 =
   1762                      _src[1].i32[_i];
   1763 
   1764                int32_t dst = (int8_t)(src0 >> (src1 * 8));
   1765 
   1766                _dst_val.i32[_i] = dst;
   1767          }
   1768 
   1769       break;
   1770    }
   1771    case 64: {
   1772 
   1773 
   1774 
   1775          for (unsigned _i = 0; _i < num_components; _i++) {
   1776                   const int64_t src0 =
   1777                      _src[0].i64[_i];
   1778                   const int64_t src1 =
   1779                      _src[1].i64[_i];
   1780 
   1781                int64_t dst = (int8_t)(src0 >> (src1 * 8));
   1782 
   1783                _dst_val.i64[_i] = dst;
   1784          }
   1785 
   1786       break;
   1787    }
   1788 
   1789    default:
   1790       unreachable("unknown bit width");
   1791    }
   1792 
   1793    return _dst_val;
   1794 }
   1795 static nir_const_value
   1796 evaluate_extract_u16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1797                  MAYBE_UNUSED nir_const_value *_src)
   1798 {
   1799    nir_const_value _dst_val = { {0, } };
   1800 
   1801    switch (bit_size) {
   1802    case 32: {
   1803 
   1804 
   1805 
   1806          for (unsigned _i = 0; _i < num_components; _i++) {
   1807                   const uint32_t src0 =
   1808                      _src[0].u32[_i];
   1809                   const uint32_t src1 =
   1810                      _src[1].u32[_i];
   1811 
   1812                uint32_t dst = (uint16_t)(src0 >> (src1 * 16));
   1813 
   1814                _dst_val.u32[_i] = dst;
   1815          }
   1816 
   1817       break;
   1818    }
   1819    case 64: {
   1820 
   1821 
   1822 
   1823          for (unsigned _i = 0; _i < num_components; _i++) {
   1824                   const uint64_t src0 =
   1825                      _src[0].u64[_i];
   1826                   const uint64_t src1 =
   1827                      _src[1].u64[_i];
   1828 
   1829                uint64_t dst = (uint16_t)(src0 >> (src1 * 16));
   1830 
   1831                _dst_val.u64[_i] = dst;
   1832          }
   1833 
   1834       break;
   1835    }
   1836 
   1837    default:
   1838       unreachable("unknown bit width");
   1839    }
   1840 
   1841    return _dst_val;
   1842 }
   1843 static nir_const_value
   1844 evaluate_extract_u8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1845                  MAYBE_UNUSED nir_const_value *_src)
   1846 {
   1847    nir_const_value _dst_val = { {0, } };
   1848 
   1849    switch (bit_size) {
   1850    case 32: {
   1851 
   1852 
   1853 
   1854          for (unsigned _i = 0; _i < num_components; _i++) {
   1855                   const uint32_t src0 =
   1856                      _src[0].u32[_i];
   1857                   const uint32_t src1 =
   1858                      _src[1].u32[_i];
   1859 
   1860                uint32_t dst = (uint8_t)(src0 >> (src1 * 8));
   1861 
   1862                _dst_val.u32[_i] = dst;
   1863          }
   1864 
   1865       break;
   1866    }
   1867    case 64: {
   1868 
   1869 
   1870 
   1871          for (unsigned _i = 0; _i < num_components; _i++) {
   1872                   const uint64_t src0 =
   1873                      _src[0].u64[_i];
   1874                   const uint64_t src1 =
   1875                      _src[1].u64[_i];
   1876 
   1877                uint64_t dst = (uint8_t)(src0 >> (src1 * 8));
   1878 
   1879                _dst_val.u64[_i] = dst;
   1880          }
   1881 
   1882       break;
   1883    }
   1884 
   1885    default:
   1886       unreachable("unknown bit width");
   1887    }
   1888 
   1889    return _dst_val;
   1890 }
   1891 static nir_const_value
   1892 evaluate_f2b(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1893                  MAYBE_UNUSED nir_const_value *_src)
   1894 {
   1895    nir_const_value _dst_val = { {0, } };
   1896 
   1897    switch (bit_size) {
   1898    case 32: {
   1899 
   1900 
   1901 
   1902          for (unsigned _i = 0; _i < num_components; _i++) {
   1903                   const float32_t src0 =
   1904                      _src[0].f32[_i];
   1905 
   1906                bool32_t dst = src0 != 0.0f;
   1907 
   1908                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   1909          }
   1910 
   1911       break;
   1912    }
   1913    case 64: {
   1914 
   1915 
   1916 
   1917          for (unsigned _i = 0; _i < num_components; _i++) {
   1918                   const float32_t src0 =
   1919                      _src[0].f32[_i];
   1920 
   1921                bool32_t dst = src0 != 0.0f;
   1922 
   1923                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   1924          }
   1925 
   1926       break;
   1927    }
   1928 
   1929    default:
   1930       unreachable("unknown bit width");
   1931    }
   1932 
   1933    return _dst_val;
   1934 }
   1935 static nir_const_value
   1936 evaluate_f2d(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1937                  MAYBE_UNUSED nir_const_value *_src)
   1938 {
   1939    nir_const_value _dst_val = { {0, } };
   1940 
   1941    switch (bit_size) {
   1942    case 32: {
   1943 
   1944 
   1945 
   1946          for (unsigned _i = 0; _i < num_components; _i++) {
   1947                   const float32_t src0 =
   1948                      _src[0].f32[_i];
   1949 
   1950                float64_t dst = src0;
   1951 
   1952                _dst_val.f64[_i] = dst;
   1953          }
   1954 
   1955       break;
   1956    }
   1957    case 64: {
   1958 
   1959 
   1960 
   1961          for (unsigned _i = 0; _i < num_components; _i++) {
   1962                   const float32_t src0 =
   1963                      _src[0].f32[_i];
   1964 
   1965                float64_t dst = src0;
   1966 
   1967                _dst_val.f64[_i] = dst;
   1968          }
   1969 
   1970       break;
   1971    }
   1972 
   1973    default:
   1974       unreachable("unknown bit width");
   1975    }
   1976 
   1977    return _dst_val;
   1978 }
   1979 static nir_const_value
   1980 evaluate_f2i(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   1981                  MAYBE_UNUSED nir_const_value *_src)
   1982 {
   1983    nir_const_value _dst_val = { {0, } };
   1984 
   1985    switch (bit_size) {
   1986    case 32: {
   1987 
   1988 
   1989 
   1990          for (unsigned _i = 0; _i < num_components; _i++) {
   1991                   const float32_t src0 =
   1992                      _src[0].f32[_i];
   1993 
   1994                int32_t dst = src0;
   1995 
   1996                _dst_val.i32[_i] = dst;
   1997          }
   1998 
   1999       break;
   2000    }
   2001    case 64: {
   2002 
   2003 
   2004 
   2005          for (unsigned _i = 0; _i < num_components; _i++) {
   2006                   const float32_t src0 =
   2007                      _src[0].f32[_i];
   2008 
   2009                int32_t dst = src0;
   2010 
   2011                _dst_val.i32[_i] = dst;
   2012          }
   2013 
   2014       break;
   2015    }
   2016 
   2017    default:
   2018       unreachable("unknown bit width");
   2019    }
   2020 
   2021    return _dst_val;
   2022 }
   2023 static nir_const_value
   2024 evaluate_f2u(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2025                  MAYBE_UNUSED nir_const_value *_src)
   2026 {
   2027    nir_const_value _dst_val = { {0, } };
   2028 
   2029    switch (bit_size) {
   2030    case 32: {
   2031 
   2032 
   2033 
   2034          for (unsigned _i = 0; _i < num_components; _i++) {
   2035                   const float32_t src0 =
   2036                      _src[0].f32[_i];
   2037 
   2038                uint32_t dst = src0;
   2039 
   2040                _dst_val.u32[_i] = dst;
   2041          }
   2042 
   2043       break;
   2044    }
   2045    case 64: {
   2046 
   2047 
   2048 
   2049          for (unsigned _i = 0; _i < num_components; _i++) {
   2050                   const float32_t src0 =
   2051                      _src[0].f32[_i];
   2052 
   2053                uint32_t dst = src0;
   2054 
   2055                _dst_val.u32[_i] = dst;
   2056          }
   2057 
   2058       break;
   2059    }
   2060 
   2061    default:
   2062       unreachable("unknown bit width");
   2063    }
   2064 
   2065    return _dst_val;
   2066 }
   2067 static nir_const_value
   2068 evaluate_fabs(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2069                  MAYBE_UNUSED nir_const_value *_src)
   2070 {
   2071    nir_const_value _dst_val = { {0, } };
   2072 
   2073    switch (bit_size) {
   2074    case 32: {
   2075 
   2076 
   2077 
   2078          for (unsigned _i = 0; _i < num_components; _i++) {
   2079                   const float32_t src0 =
   2080                      _src[0].f32[_i];
   2081 
   2082                float32_t dst = bit_size == 64 ? fabs(src0) : fabsf(src0);
   2083 
   2084                _dst_val.f32[_i] = dst;
   2085          }
   2086 
   2087       break;
   2088    }
   2089    case 64: {
   2090 
   2091 
   2092 
   2093          for (unsigned _i = 0; _i < num_components; _i++) {
   2094                   const float64_t src0 =
   2095                      _src[0].f64[_i];
   2096 
   2097                float64_t dst = bit_size == 64 ? fabs(src0) : fabsf(src0);
   2098 
   2099                _dst_val.f64[_i] = dst;
   2100          }
   2101 
   2102       break;
   2103    }
   2104 
   2105    default:
   2106       unreachable("unknown bit width");
   2107    }
   2108 
   2109    return _dst_val;
   2110 }
   2111 static nir_const_value
   2112 evaluate_fadd(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2113                  MAYBE_UNUSED nir_const_value *_src)
   2114 {
   2115    nir_const_value _dst_val = { {0, } };
   2116 
   2117    switch (bit_size) {
   2118    case 32: {
   2119 
   2120 
   2121 
   2122          for (unsigned _i = 0; _i < num_components; _i++) {
   2123                   const float32_t src0 =
   2124                      _src[0].f32[_i];
   2125                   const float32_t src1 =
   2126                      _src[1].f32[_i];
   2127 
   2128                float32_t dst = src0 + src1;
   2129 
   2130                _dst_val.f32[_i] = dst;
   2131          }
   2132 
   2133       break;
   2134    }
   2135    case 64: {
   2136 
   2137 
   2138 
   2139          for (unsigned _i = 0; _i < num_components; _i++) {
   2140                   const float64_t src0 =
   2141                      _src[0].f64[_i];
   2142                   const float64_t src1 =
   2143                      _src[1].f64[_i];
   2144 
   2145                float64_t dst = src0 + src1;
   2146 
   2147                _dst_val.f64[_i] = dst;
   2148          }
   2149 
   2150       break;
   2151    }
   2152 
   2153    default:
   2154       unreachable("unknown bit width");
   2155    }
   2156 
   2157    return _dst_val;
   2158 }
   2159 static nir_const_value
   2160 evaluate_fall_equal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2161                  MAYBE_UNUSED nir_const_value *_src)
   2162 {
   2163    nir_const_value _dst_val = { {0, } };
   2164 
   2165    switch (bit_size) {
   2166    case 32: {
   2167 
   2168 
   2169 
   2170          const struct float32_vec src0 = {
   2171                _src[0].f32[0],
   2172                _src[0].f32[1],
   2173             0,
   2174             0,
   2175          };
   2176 
   2177          const struct float32_vec src1 = {
   2178                _src[1].f32[0],
   2179                _src[1].f32[1],
   2180             0,
   2181             0,
   2182          };
   2183 
   2184          struct float32_vec dst;
   2185 
   2186             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y)) ? 1.0f : 0.0f;
   2187 
   2188                _dst_val.f32[0] = dst.x;
   2189 
   2190       break;
   2191    }
   2192    case 64: {
   2193 
   2194 
   2195 
   2196          const struct float32_vec src0 = {
   2197                _src[0].f32[0],
   2198                _src[0].f32[1],
   2199             0,
   2200             0,
   2201          };
   2202 
   2203          const struct float32_vec src1 = {
   2204                _src[1].f32[0],
   2205                _src[1].f32[1],
   2206             0,
   2207             0,
   2208          };
   2209 
   2210          struct float32_vec dst;
   2211 
   2212             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y)) ? 1.0f : 0.0f;
   2213 
   2214                _dst_val.f32[0] = dst.x;
   2215 
   2216       break;
   2217    }
   2218 
   2219    default:
   2220       unreachable("unknown bit width");
   2221    }
   2222 
   2223    return _dst_val;
   2224 }
   2225 static nir_const_value
   2226 evaluate_fall_equal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2227                  MAYBE_UNUSED nir_const_value *_src)
   2228 {
   2229    nir_const_value _dst_val = { {0, } };
   2230 
   2231    switch (bit_size) {
   2232    case 32: {
   2233 
   2234 
   2235 
   2236          const struct float32_vec src0 = {
   2237                _src[0].f32[0],
   2238                _src[0].f32[1],
   2239                _src[0].f32[2],
   2240             0,
   2241          };
   2242 
   2243          const struct float32_vec src1 = {
   2244                _src[1].f32[0],
   2245                _src[1].f32[1],
   2246                _src[1].f32[2],
   2247             0,
   2248          };
   2249 
   2250          struct float32_vec dst;
   2251 
   2252             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z)) ? 1.0f : 0.0f;
   2253 
   2254                _dst_val.f32[0] = dst.x;
   2255 
   2256       break;
   2257    }
   2258    case 64: {
   2259 
   2260 
   2261 
   2262          const struct float32_vec src0 = {
   2263                _src[0].f32[0],
   2264                _src[0].f32[1],
   2265                _src[0].f32[2],
   2266             0,
   2267          };
   2268 
   2269          const struct float32_vec src1 = {
   2270                _src[1].f32[0],
   2271                _src[1].f32[1],
   2272                _src[1].f32[2],
   2273             0,
   2274          };
   2275 
   2276          struct float32_vec dst;
   2277 
   2278             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z)) ? 1.0f : 0.0f;
   2279 
   2280                _dst_val.f32[0] = dst.x;
   2281 
   2282       break;
   2283    }
   2284 
   2285    default:
   2286       unreachable("unknown bit width");
   2287    }
   2288 
   2289    return _dst_val;
   2290 }
   2291 static nir_const_value
   2292 evaluate_fall_equal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2293                  MAYBE_UNUSED nir_const_value *_src)
   2294 {
   2295    nir_const_value _dst_val = { {0, } };
   2296 
   2297    switch (bit_size) {
   2298    case 32: {
   2299 
   2300 
   2301 
   2302          const struct float32_vec src0 = {
   2303                _src[0].f32[0],
   2304                _src[0].f32[1],
   2305                _src[0].f32[2],
   2306                _src[0].f32[3],
   2307          };
   2308 
   2309          const struct float32_vec src1 = {
   2310                _src[1].f32[0],
   2311                _src[1].f32[1],
   2312                _src[1].f32[2],
   2313                _src[1].f32[3],
   2314          };
   2315 
   2316          struct float32_vec dst;
   2317 
   2318             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w)) ? 1.0f : 0.0f;
   2319 
   2320                _dst_val.f32[0] = dst.x;
   2321 
   2322       break;
   2323    }
   2324    case 64: {
   2325 
   2326 
   2327 
   2328          const struct float32_vec src0 = {
   2329                _src[0].f32[0],
   2330                _src[0].f32[1],
   2331                _src[0].f32[2],
   2332                _src[0].f32[3],
   2333          };
   2334 
   2335          const struct float32_vec src1 = {
   2336                _src[1].f32[0],
   2337                _src[1].f32[1],
   2338                _src[1].f32[2],
   2339                _src[1].f32[3],
   2340          };
   2341 
   2342          struct float32_vec dst;
   2343 
   2344             dst.x = dst.y = dst.z = dst.w = ((src0.x == src1.x) && (src0.y == src1.y) && (src0.z == src1.z) && (src0.w == src1.w)) ? 1.0f : 0.0f;
   2345 
   2346                _dst_val.f32[0] = dst.x;
   2347 
   2348       break;
   2349    }
   2350 
   2351    default:
   2352       unreachable("unknown bit width");
   2353    }
   2354 
   2355    return _dst_val;
   2356 }
   2357 static nir_const_value
   2358 evaluate_fand(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2359                  MAYBE_UNUSED nir_const_value *_src)
   2360 {
   2361    nir_const_value _dst_val = { {0, } };
   2362 
   2363    switch (bit_size) {
   2364    case 32: {
   2365 
   2366 
   2367 
   2368          for (unsigned _i = 0; _i < num_components; _i++) {
   2369                   const float32_t src0 =
   2370                      _src[0].f32[_i];
   2371                   const float32_t src1 =
   2372                      _src[1].f32[_i];
   2373 
   2374                float32_t dst = ((src0 != 0.0f) && (src1 != 0.0f)) ? 1.0f : 0.0f;
   2375 
   2376                _dst_val.f32[_i] = dst;
   2377          }
   2378 
   2379       break;
   2380    }
   2381    case 64: {
   2382 
   2383 
   2384 
   2385          for (unsigned _i = 0; _i < num_components; _i++) {
   2386                   const float32_t src0 =
   2387                      _src[0].f32[_i];
   2388                   const float32_t src1 =
   2389                      _src[1].f32[_i];
   2390 
   2391                float32_t dst = ((src0 != 0.0f) && (src1 != 0.0f)) ? 1.0f : 0.0f;
   2392 
   2393                _dst_val.f32[_i] = dst;
   2394          }
   2395 
   2396       break;
   2397    }
   2398 
   2399    default:
   2400       unreachable("unknown bit width");
   2401    }
   2402 
   2403    return _dst_val;
   2404 }
   2405 static nir_const_value
   2406 evaluate_fany_nequal2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2407                  MAYBE_UNUSED nir_const_value *_src)
   2408 {
   2409    nir_const_value _dst_val = { {0, } };
   2410 
   2411    switch (bit_size) {
   2412    case 32: {
   2413 
   2414 
   2415 
   2416          const struct float32_vec src0 = {
   2417                _src[0].f32[0],
   2418                _src[0].f32[1],
   2419             0,
   2420             0,
   2421          };
   2422 
   2423          const struct float32_vec src1 = {
   2424                _src[1].f32[0],
   2425                _src[1].f32[1],
   2426             0,
   2427             0,
   2428          };
   2429 
   2430          struct float32_vec dst;
   2431 
   2432             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y)) ? 1.0f : 0.0f;
   2433 
   2434                _dst_val.f32[0] = dst.x;
   2435 
   2436       break;
   2437    }
   2438    case 64: {
   2439 
   2440 
   2441 
   2442          const struct float32_vec src0 = {
   2443                _src[0].f32[0],
   2444                _src[0].f32[1],
   2445             0,
   2446             0,
   2447          };
   2448 
   2449          const struct float32_vec src1 = {
   2450                _src[1].f32[0],
   2451                _src[1].f32[1],
   2452             0,
   2453             0,
   2454          };
   2455 
   2456          struct float32_vec dst;
   2457 
   2458             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y)) ? 1.0f : 0.0f;
   2459 
   2460                _dst_val.f32[0] = dst.x;
   2461 
   2462       break;
   2463    }
   2464 
   2465    default:
   2466       unreachable("unknown bit width");
   2467    }
   2468 
   2469    return _dst_val;
   2470 }
   2471 static nir_const_value
   2472 evaluate_fany_nequal3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2473                  MAYBE_UNUSED nir_const_value *_src)
   2474 {
   2475    nir_const_value _dst_val = { {0, } };
   2476 
   2477    switch (bit_size) {
   2478    case 32: {
   2479 
   2480 
   2481 
   2482          const struct float32_vec src0 = {
   2483                _src[0].f32[0],
   2484                _src[0].f32[1],
   2485                _src[0].f32[2],
   2486             0,
   2487          };
   2488 
   2489          const struct float32_vec src1 = {
   2490                _src[1].f32[0],
   2491                _src[1].f32[1],
   2492                _src[1].f32[2],
   2493             0,
   2494          };
   2495 
   2496          struct float32_vec dst;
   2497 
   2498             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z)) ? 1.0f : 0.0f;
   2499 
   2500                _dst_val.f32[0] = dst.x;
   2501 
   2502       break;
   2503    }
   2504    case 64: {
   2505 
   2506 
   2507 
   2508          const struct float32_vec src0 = {
   2509                _src[0].f32[0],
   2510                _src[0].f32[1],
   2511                _src[0].f32[2],
   2512             0,
   2513          };
   2514 
   2515          const struct float32_vec src1 = {
   2516                _src[1].f32[0],
   2517                _src[1].f32[1],
   2518                _src[1].f32[2],
   2519             0,
   2520          };
   2521 
   2522          struct float32_vec dst;
   2523 
   2524             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z)) ? 1.0f : 0.0f;
   2525 
   2526                _dst_val.f32[0] = dst.x;
   2527 
   2528       break;
   2529    }
   2530 
   2531    default:
   2532       unreachable("unknown bit width");
   2533    }
   2534 
   2535    return _dst_val;
   2536 }
   2537 static nir_const_value
   2538 evaluate_fany_nequal4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2539                  MAYBE_UNUSED nir_const_value *_src)
   2540 {
   2541    nir_const_value _dst_val = { {0, } };
   2542 
   2543    switch (bit_size) {
   2544    case 32: {
   2545 
   2546 
   2547 
   2548          const struct float32_vec src0 = {
   2549                _src[0].f32[0],
   2550                _src[0].f32[1],
   2551                _src[0].f32[2],
   2552                _src[0].f32[3],
   2553          };
   2554 
   2555          const struct float32_vec src1 = {
   2556                _src[1].f32[0],
   2557                _src[1].f32[1],
   2558                _src[1].f32[2],
   2559                _src[1].f32[3],
   2560          };
   2561 
   2562          struct float32_vec dst;
   2563 
   2564             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w)) ? 1.0f : 0.0f;
   2565 
   2566                _dst_val.f32[0] = dst.x;
   2567 
   2568       break;
   2569    }
   2570    case 64: {
   2571 
   2572 
   2573 
   2574          const struct float32_vec src0 = {
   2575                _src[0].f32[0],
   2576                _src[0].f32[1],
   2577                _src[0].f32[2],
   2578                _src[0].f32[3],
   2579          };
   2580 
   2581          const struct float32_vec src1 = {
   2582                _src[1].f32[0],
   2583                _src[1].f32[1],
   2584                _src[1].f32[2],
   2585                _src[1].f32[3],
   2586          };
   2587 
   2588          struct float32_vec dst;
   2589 
   2590             dst.x = dst.y = dst.z = dst.w = ((src0.x != src1.x) || (src0.y != src1.y) || (src0.z != src1.z) || (src0.w != src1.w)) ? 1.0f : 0.0f;
   2591 
   2592                _dst_val.f32[0] = dst.x;
   2593 
   2594       break;
   2595    }
   2596 
   2597    default:
   2598       unreachable("unknown bit width");
   2599    }
   2600 
   2601    return _dst_val;
   2602 }
   2603 static nir_const_value
   2604 evaluate_fceil(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2605                  MAYBE_UNUSED nir_const_value *_src)
   2606 {
   2607    nir_const_value _dst_val = { {0, } };
   2608 
   2609    switch (bit_size) {
   2610    case 32: {
   2611 
   2612 
   2613 
   2614          for (unsigned _i = 0; _i < num_components; _i++) {
   2615                   const float32_t src0 =
   2616                      _src[0].f32[_i];
   2617 
   2618                float32_t dst = bit_size == 64 ? ceil(src0) : ceilf(src0);
   2619 
   2620                _dst_val.f32[_i] = dst;
   2621          }
   2622 
   2623       break;
   2624    }
   2625    case 64: {
   2626 
   2627 
   2628 
   2629          for (unsigned _i = 0; _i < num_components; _i++) {
   2630                   const float64_t src0 =
   2631                      _src[0].f64[_i];
   2632 
   2633                float64_t dst = bit_size == 64 ? ceil(src0) : ceilf(src0);
   2634 
   2635                _dst_val.f64[_i] = dst;
   2636          }
   2637 
   2638       break;
   2639    }
   2640 
   2641    default:
   2642       unreachable("unknown bit width");
   2643    }
   2644 
   2645    return _dst_val;
   2646 }
   2647 static nir_const_value
   2648 evaluate_fcos(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2649                  MAYBE_UNUSED nir_const_value *_src)
   2650 {
   2651    nir_const_value _dst_val = { {0, } };
   2652 
   2653    switch (bit_size) {
   2654    case 32: {
   2655 
   2656 
   2657 
   2658          for (unsigned _i = 0; _i < num_components; _i++) {
   2659                   const float32_t src0 =
   2660                      _src[0].f32[_i];
   2661 
   2662                float32_t dst = bit_size == 64 ? cos(src0) : cosf(src0);
   2663 
   2664                _dst_val.f32[_i] = dst;
   2665          }
   2666 
   2667       break;
   2668    }
   2669    case 64: {
   2670 
   2671 
   2672 
   2673          for (unsigned _i = 0; _i < num_components; _i++) {
   2674                   const float64_t src0 =
   2675                      _src[0].f64[_i];
   2676 
   2677                float64_t dst = bit_size == 64 ? cos(src0) : cosf(src0);
   2678 
   2679                _dst_val.f64[_i] = dst;
   2680          }
   2681 
   2682       break;
   2683    }
   2684 
   2685    default:
   2686       unreachable("unknown bit width");
   2687    }
   2688 
   2689    return _dst_val;
   2690 }
   2691 static nir_const_value
   2692 evaluate_fcsel(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2693                  MAYBE_UNUSED nir_const_value *_src)
   2694 {
   2695    nir_const_value _dst_val = { {0, } };
   2696 
   2697    switch (bit_size) {
   2698    case 32: {
   2699 
   2700 
   2701 
   2702          for (unsigned _i = 0; _i < num_components; _i++) {
   2703                   const float32_t src0 =
   2704                      _src[0].f32[_i];
   2705                   const float32_t src1 =
   2706                      _src[1].f32[_i];
   2707                   const float32_t src2 =
   2708                      _src[2].f32[_i];
   2709 
   2710                float32_t dst = (src0 != 0.0f) ? src1 : src2;
   2711 
   2712                _dst_val.f32[_i] = dst;
   2713          }
   2714 
   2715       break;
   2716    }
   2717    case 64: {
   2718 
   2719 
   2720 
   2721          for (unsigned _i = 0; _i < num_components; _i++) {
   2722                   const float32_t src0 =
   2723                      _src[0].f32[_i];
   2724                   const float32_t src1 =
   2725                      _src[1].f32[_i];
   2726                   const float32_t src2 =
   2727                      _src[2].f32[_i];
   2728 
   2729                float32_t dst = (src0 != 0.0f) ? src1 : src2;
   2730 
   2731                _dst_val.f32[_i] = dst;
   2732          }
   2733 
   2734       break;
   2735    }
   2736 
   2737    default:
   2738       unreachable("unknown bit width");
   2739    }
   2740 
   2741    return _dst_val;
   2742 }
   2743 static nir_const_value
   2744 evaluate_fddx(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2745                  MAYBE_UNUSED nir_const_value *_src)
   2746 {
   2747    nir_const_value _dst_val = { {0, } };
   2748 
   2749    switch (bit_size) {
   2750    case 32: {
   2751 
   2752 
   2753 
   2754          for (unsigned _i = 0; _i < num_components; _i++) {
   2755 
   2756                float32_t dst = 0.0;
   2757 
   2758                _dst_val.f32[_i] = dst;
   2759          }
   2760 
   2761       break;
   2762    }
   2763    case 64: {
   2764 
   2765 
   2766 
   2767          for (unsigned _i = 0; _i < num_components; _i++) {
   2768 
   2769                float64_t dst = 0.0;
   2770 
   2771                _dst_val.f64[_i] = dst;
   2772          }
   2773 
   2774       break;
   2775    }
   2776 
   2777    default:
   2778       unreachable("unknown bit width");
   2779    }
   2780 
   2781    return _dst_val;
   2782 }
   2783 static nir_const_value
   2784 evaluate_fddx_coarse(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2785                  MAYBE_UNUSED nir_const_value *_src)
   2786 {
   2787    nir_const_value _dst_val = { {0, } };
   2788 
   2789    switch (bit_size) {
   2790    case 32: {
   2791 
   2792 
   2793 
   2794          for (unsigned _i = 0; _i < num_components; _i++) {
   2795 
   2796                float32_t dst = 0.0;
   2797 
   2798                _dst_val.f32[_i] = dst;
   2799          }
   2800 
   2801       break;
   2802    }
   2803    case 64: {
   2804 
   2805 
   2806 
   2807          for (unsigned _i = 0; _i < num_components; _i++) {
   2808 
   2809                float64_t dst = 0.0;
   2810 
   2811                _dst_val.f64[_i] = dst;
   2812          }
   2813 
   2814       break;
   2815    }
   2816 
   2817    default:
   2818       unreachable("unknown bit width");
   2819    }
   2820 
   2821    return _dst_val;
   2822 }
   2823 static nir_const_value
   2824 evaluate_fddx_fine(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2825                  MAYBE_UNUSED nir_const_value *_src)
   2826 {
   2827    nir_const_value _dst_val = { {0, } };
   2828 
   2829    switch (bit_size) {
   2830    case 32: {
   2831 
   2832 
   2833 
   2834          for (unsigned _i = 0; _i < num_components; _i++) {
   2835 
   2836                float32_t dst = 0.0;
   2837 
   2838                _dst_val.f32[_i] = dst;
   2839          }
   2840 
   2841       break;
   2842    }
   2843    case 64: {
   2844 
   2845 
   2846 
   2847          for (unsigned _i = 0; _i < num_components; _i++) {
   2848 
   2849                float64_t dst = 0.0;
   2850 
   2851                _dst_val.f64[_i] = dst;
   2852          }
   2853 
   2854       break;
   2855    }
   2856 
   2857    default:
   2858       unreachable("unknown bit width");
   2859    }
   2860 
   2861    return _dst_val;
   2862 }
   2863 static nir_const_value
   2864 evaluate_fddy(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2865                  MAYBE_UNUSED nir_const_value *_src)
   2866 {
   2867    nir_const_value _dst_val = { {0, } };
   2868 
   2869    switch (bit_size) {
   2870    case 32: {
   2871 
   2872 
   2873 
   2874          for (unsigned _i = 0; _i < num_components; _i++) {
   2875 
   2876                float32_t dst = 0.0;
   2877 
   2878                _dst_val.f32[_i] = dst;
   2879          }
   2880 
   2881       break;
   2882    }
   2883    case 64: {
   2884 
   2885 
   2886 
   2887          for (unsigned _i = 0; _i < num_components; _i++) {
   2888 
   2889                float64_t dst = 0.0;
   2890 
   2891                _dst_val.f64[_i] = dst;
   2892          }
   2893 
   2894       break;
   2895    }
   2896 
   2897    default:
   2898       unreachable("unknown bit width");
   2899    }
   2900 
   2901    return _dst_val;
   2902 }
   2903 static nir_const_value
   2904 evaluate_fddy_coarse(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2905                  MAYBE_UNUSED nir_const_value *_src)
   2906 {
   2907    nir_const_value _dst_val = { {0, } };
   2908 
   2909    switch (bit_size) {
   2910    case 32: {
   2911 
   2912 
   2913 
   2914          for (unsigned _i = 0; _i < num_components; _i++) {
   2915 
   2916                float32_t dst = 0.0;
   2917 
   2918                _dst_val.f32[_i] = dst;
   2919          }
   2920 
   2921       break;
   2922    }
   2923    case 64: {
   2924 
   2925 
   2926 
   2927          for (unsigned _i = 0; _i < num_components; _i++) {
   2928 
   2929                float64_t dst = 0.0;
   2930 
   2931                _dst_val.f64[_i] = dst;
   2932          }
   2933 
   2934       break;
   2935    }
   2936 
   2937    default:
   2938       unreachable("unknown bit width");
   2939    }
   2940 
   2941    return _dst_val;
   2942 }
   2943 static nir_const_value
   2944 evaluate_fddy_fine(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2945                  MAYBE_UNUSED nir_const_value *_src)
   2946 {
   2947    nir_const_value _dst_val = { {0, } };
   2948 
   2949    switch (bit_size) {
   2950    case 32: {
   2951 
   2952 
   2953 
   2954          for (unsigned _i = 0; _i < num_components; _i++) {
   2955 
   2956                float32_t dst = 0.0;
   2957 
   2958                _dst_val.f32[_i] = dst;
   2959          }
   2960 
   2961       break;
   2962    }
   2963    case 64: {
   2964 
   2965 
   2966 
   2967          for (unsigned _i = 0; _i < num_components; _i++) {
   2968 
   2969                float64_t dst = 0.0;
   2970 
   2971                _dst_val.f64[_i] = dst;
   2972          }
   2973 
   2974       break;
   2975    }
   2976 
   2977    default:
   2978       unreachable("unknown bit width");
   2979    }
   2980 
   2981    return _dst_val;
   2982 }
   2983 static nir_const_value
   2984 evaluate_fdiv(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   2985                  MAYBE_UNUSED nir_const_value *_src)
   2986 {
   2987    nir_const_value _dst_val = { {0, } };
   2988 
   2989    switch (bit_size) {
   2990    case 32: {
   2991 
   2992 
   2993 
   2994          for (unsigned _i = 0; _i < num_components; _i++) {
   2995                   const float32_t src0 =
   2996                      _src[0].f32[_i];
   2997                   const float32_t src1 =
   2998                      _src[1].f32[_i];
   2999 
   3000                float32_t dst = src0 / src1;
   3001 
   3002                _dst_val.f32[_i] = dst;
   3003          }
   3004 
   3005       break;
   3006    }
   3007    case 64: {
   3008 
   3009 
   3010 
   3011          for (unsigned _i = 0; _i < num_components; _i++) {
   3012                   const float64_t src0 =
   3013                      _src[0].f64[_i];
   3014                   const float64_t src1 =
   3015                      _src[1].f64[_i];
   3016 
   3017                float64_t dst = src0 / src1;
   3018 
   3019                _dst_val.f64[_i] = dst;
   3020          }
   3021 
   3022       break;
   3023    }
   3024 
   3025    default:
   3026       unreachable("unknown bit width");
   3027    }
   3028 
   3029    return _dst_val;
   3030 }
   3031 static nir_const_value
   3032 evaluate_fdot2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3033                  MAYBE_UNUSED nir_const_value *_src)
   3034 {
   3035    nir_const_value _dst_val = { {0, } };
   3036 
   3037    switch (bit_size) {
   3038    case 32: {
   3039 
   3040 
   3041 
   3042          const struct float32_vec src0 = {
   3043                _src[0].f32[0],
   3044                _src[0].f32[1],
   3045             0,
   3046             0,
   3047          };
   3048 
   3049          const struct float32_vec src1 = {
   3050                _src[1].f32[0],
   3051                _src[1].f32[1],
   3052             0,
   3053             0,
   3054          };
   3055 
   3056          struct float32_vec dst;
   3057 
   3058             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y));
   3059 
   3060                _dst_val.f32[0] = dst.x;
   3061 
   3062       break;
   3063    }
   3064    case 64: {
   3065 
   3066 
   3067 
   3068          const struct float64_vec src0 = {
   3069                _src[0].f64[0],
   3070                _src[0].f64[1],
   3071             0,
   3072             0,
   3073          };
   3074 
   3075          const struct float64_vec src1 = {
   3076                _src[1].f64[0],
   3077                _src[1].f64[1],
   3078             0,
   3079             0,
   3080          };
   3081 
   3082          struct float64_vec dst;
   3083 
   3084             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y));
   3085 
   3086                _dst_val.f64[0] = dst.x;
   3087 
   3088       break;
   3089    }
   3090 
   3091    default:
   3092       unreachable("unknown bit width");
   3093    }
   3094 
   3095    return _dst_val;
   3096 }
   3097 static nir_const_value
   3098 evaluate_fdot3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3099                  MAYBE_UNUSED nir_const_value *_src)
   3100 {
   3101    nir_const_value _dst_val = { {0, } };
   3102 
   3103    switch (bit_size) {
   3104    case 32: {
   3105 
   3106 
   3107 
   3108          const struct float32_vec src0 = {
   3109                _src[0].f32[0],
   3110                _src[0].f32[1],
   3111                _src[0].f32[2],
   3112             0,
   3113          };
   3114 
   3115          const struct float32_vec src1 = {
   3116                _src[1].f32[0],
   3117                _src[1].f32[1],
   3118                _src[1].f32[2],
   3119             0,
   3120          };
   3121 
   3122          struct float32_vec dst;
   3123 
   3124             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z));
   3125 
   3126                _dst_val.f32[0] = dst.x;
   3127 
   3128       break;
   3129    }
   3130    case 64: {
   3131 
   3132 
   3133 
   3134          const struct float64_vec src0 = {
   3135                _src[0].f64[0],
   3136                _src[0].f64[1],
   3137                _src[0].f64[2],
   3138             0,
   3139          };
   3140 
   3141          const struct float64_vec src1 = {
   3142                _src[1].f64[0],
   3143                _src[1].f64[1],
   3144                _src[1].f64[2],
   3145             0,
   3146          };
   3147 
   3148          struct float64_vec dst;
   3149 
   3150             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z));
   3151 
   3152                _dst_val.f64[0] = dst.x;
   3153 
   3154       break;
   3155    }
   3156 
   3157    default:
   3158       unreachable("unknown bit width");
   3159    }
   3160 
   3161    return _dst_val;
   3162 }
   3163 static nir_const_value
   3164 evaluate_fdot4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3165                  MAYBE_UNUSED nir_const_value *_src)
   3166 {
   3167    nir_const_value _dst_val = { {0, } };
   3168 
   3169    switch (bit_size) {
   3170    case 32: {
   3171 
   3172 
   3173 
   3174          const struct float32_vec src0 = {
   3175                _src[0].f32[0],
   3176                _src[0].f32[1],
   3177                _src[0].f32[2],
   3178                _src[0].f32[3],
   3179          };
   3180 
   3181          const struct float32_vec src1 = {
   3182                _src[1].f32[0],
   3183                _src[1].f32[1],
   3184                _src[1].f32[2],
   3185                _src[1].f32[3],
   3186          };
   3187 
   3188          struct float32_vec dst;
   3189 
   3190             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w));
   3191 
   3192                _dst_val.f32[0] = dst.x;
   3193 
   3194       break;
   3195    }
   3196    case 64: {
   3197 
   3198 
   3199 
   3200          const struct float64_vec src0 = {
   3201                _src[0].f64[0],
   3202                _src[0].f64[1],
   3203                _src[0].f64[2],
   3204                _src[0].f64[3],
   3205          };
   3206 
   3207          const struct float64_vec src1 = {
   3208                _src[1].f64[0],
   3209                _src[1].f64[1],
   3210                _src[1].f64[2],
   3211                _src[1].f64[3],
   3212          };
   3213 
   3214          struct float64_vec dst;
   3215 
   3216             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w));
   3217 
   3218                _dst_val.f64[0] = dst.x;
   3219 
   3220       break;
   3221    }
   3222 
   3223    default:
   3224       unreachable("unknown bit width");
   3225    }
   3226 
   3227    return _dst_val;
   3228 }
   3229 static nir_const_value
   3230 evaluate_fdot_replicated2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3231                  MAYBE_UNUSED nir_const_value *_src)
   3232 {
   3233    nir_const_value _dst_val = { {0, } };
   3234 
   3235    switch (bit_size) {
   3236    case 32: {
   3237 
   3238 
   3239 
   3240          const struct float32_vec src0 = {
   3241                _src[0].f32[0],
   3242                _src[0].f32[1],
   3243             0,
   3244             0,
   3245          };
   3246 
   3247          const struct float32_vec src1 = {
   3248                _src[1].f32[0],
   3249                _src[1].f32[1],
   3250             0,
   3251             0,
   3252          };
   3253 
   3254          struct float32_vec dst;
   3255 
   3256             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y));
   3257 
   3258                _dst_val.f32[0] = dst.x;
   3259                _dst_val.f32[1] = dst.y;
   3260                _dst_val.f32[2] = dst.z;
   3261                _dst_val.f32[3] = dst.w;
   3262 
   3263       break;
   3264    }
   3265    case 64: {
   3266 
   3267 
   3268 
   3269          const struct float64_vec src0 = {
   3270                _src[0].f64[0],
   3271                _src[0].f64[1],
   3272             0,
   3273             0,
   3274          };
   3275 
   3276          const struct float64_vec src1 = {
   3277                _src[1].f64[0],
   3278                _src[1].f64[1],
   3279             0,
   3280             0,
   3281          };
   3282 
   3283          struct float64_vec dst;
   3284 
   3285             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y));
   3286 
   3287                _dst_val.f64[0] = dst.x;
   3288                _dst_val.f64[1] = dst.y;
   3289                _dst_val.f64[2] = dst.z;
   3290                _dst_val.f64[3] = dst.w;
   3291 
   3292       break;
   3293    }
   3294 
   3295    default:
   3296       unreachable("unknown bit width");
   3297    }
   3298 
   3299    return _dst_val;
   3300 }
   3301 static nir_const_value
   3302 evaluate_fdot_replicated3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3303                  MAYBE_UNUSED nir_const_value *_src)
   3304 {
   3305    nir_const_value _dst_val = { {0, } };
   3306 
   3307    switch (bit_size) {
   3308    case 32: {
   3309 
   3310 
   3311 
   3312          const struct float32_vec src0 = {
   3313                _src[0].f32[0],
   3314                _src[0].f32[1],
   3315                _src[0].f32[2],
   3316             0,
   3317          };
   3318 
   3319          const struct float32_vec src1 = {
   3320                _src[1].f32[0],
   3321                _src[1].f32[1],
   3322                _src[1].f32[2],
   3323             0,
   3324          };
   3325 
   3326          struct float32_vec dst;
   3327 
   3328             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z));
   3329 
   3330                _dst_val.f32[0] = dst.x;
   3331                _dst_val.f32[1] = dst.y;
   3332                _dst_val.f32[2] = dst.z;
   3333                _dst_val.f32[3] = dst.w;
   3334 
   3335       break;
   3336    }
   3337    case 64: {
   3338 
   3339 
   3340 
   3341          const struct float64_vec src0 = {
   3342                _src[0].f64[0],
   3343                _src[0].f64[1],
   3344                _src[0].f64[2],
   3345             0,
   3346          };
   3347 
   3348          const struct float64_vec src1 = {
   3349                _src[1].f64[0],
   3350                _src[1].f64[1],
   3351                _src[1].f64[2],
   3352             0,
   3353          };
   3354 
   3355          struct float64_vec dst;
   3356 
   3357             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z));
   3358 
   3359                _dst_val.f64[0] = dst.x;
   3360                _dst_val.f64[1] = dst.y;
   3361                _dst_val.f64[2] = dst.z;
   3362                _dst_val.f64[3] = dst.w;
   3363 
   3364       break;
   3365    }
   3366 
   3367    default:
   3368       unreachable("unknown bit width");
   3369    }
   3370 
   3371    return _dst_val;
   3372 }
   3373 static nir_const_value
   3374 evaluate_fdot_replicated4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3375                  MAYBE_UNUSED nir_const_value *_src)
   3376 {
   3377    nir_const_value _dst_val = { {0, } };
   3378 
   3379    switch (bit_size) {
   3380    case 32: {
   3381 
   3382 
   3383 
   3384          const struct float32_vec src0 = {
   3385                _src[0].f32[0],
   3386                _src[0].f32[1],
   3387                _src[0].f32[2],
   3388                _src[0].f32[3],
   3389          };
   3390 
   3391          const struct float32_vec src1 = {
   3392                _src[1].f32[0],
   3393                _src[1].f32[1],
   3394                _src[1].f32[2],
   3395                _src[1].f32[3],
   3396          };
   3397 
   3398          struct float32_vec dst;
   3399 
   3400             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w));
   3401 
   3402                _dst_val.f32[0] = dst.x;
   3403                _dst_val.f32[1] = dst.y;
   3404                _dst_val.f32[2] = dst.z;
   3405                _dst_val.f32[3] = dst.w;
   3406 
   3407       break;
   3408    }
   3409    case 64: {
   3410 
   3411 
   3412 
   3413          const struct float64_vec src0 = {
   3414                _src[0].f64[0],
   3415                _src[0].f64[1],
   3416                _src[0].f64[2],
   3417                _src[0].f64[3],
   3418          };
   3419 
   3420          const struct float64_vec src1 = {
   3421                _src[1].f64[0],
   3422                _src[1].f64[1],
   3423                _src[1].f64[2],
   3424                _src[1].f64[3],
   3425          };
   3426 
   3427          struct float64_vec dst;
   3428 
   3429             dst.x = dst.y = dst.z = dst.w = ((src0.x * src1.x) + (src0.y * src1.y) + (src0.z * src1.z) + (src0.w * src1.w));
   3430 
   3431                _dst_val.f64[0] = dst.x;
   3432                _dst_val.f64[1] = dst.y;
   3433                _dst_val.f64[2] = dst.z;
   3434                _dst_val.f64[3] = dst.w;
   3435 
   3436       break;
   3437    }
   3438 
   3439    default:
   3440       unreachable("unknown bit width");
   3441    }
   3442 
   3443    return _dst_val;
   3444 }
   3445 static nir_const_value
   3446 evaluate_fdph(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3447                  MAYBE_UNUSED nir_const_value *_src)
   3448 {
   3449    nir_const_value _dst_val = { {0, } };
   3450 
   3451    switch (bit_size) {
   3452    case 32: {
   3453 
   3454 
   3455 
   3456          const struct float32_vec src0 = {
   3457                _src[0].f32[0],
   3458                _src[0].f32[1],
   3459                _src[0].f32[2],
   3460             0,
   3461          };
   3462 
   3463          const struct float32_vec src1 = {
   3464                _src[1].f32[0],
   3465                _src[1].f32[1],
   3466                _src[1].f32[2],
   3467                _src[1].f32[3],
   3468          };
   3469 
   3470          struct float32_vec dst;
   3471 
   3472             dst.x = dst.y = dst.z = dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w;
   3473 
   3474                _dst_val.f32[0] = dst.x;
   3475 
   3476       break;
   3477    }
   3478    case 64: {
   3479 
   3480 
   3481 
   3482          const struct float64_vec src0 = {
   3483                _src[0].f64[0],
   3484                _src[0].f64[1],
   3485                _src[0].f64[2],
   3486             0,
   3487          };
   3488 
   3489          const struct float64_vec src1 = {
   3490                _src[1].f64[0],
   3491                _src[1].f64[1],
   3492                _src[1].f64[2],
   3493                _src[1].f64[3],
   3494          };
   3495 
   3496          struct float64_vec dst;
   3497 
   3498             dst.x = dst.y = dst.z = dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w;
   3499 
   3500                _dst_val.f64[0] = dst.x;
   3501 
   3502       break;
   3503    }
   3504 
   3505    default:
   3506       unreachable("unknown bit width");
   3507    }
   3508 
   3509    return _dst_val;
   3510 }
   3511 static nir_const_value
   3512 evaluate_fdph_replicated(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3513                  MAYBE_UNUSED nir_const_value *_src)
   3514 {
   3515    nir_const_value _dst_val = { {0, } };
   3516 
   3517    switch (bit_size) {
   3518    case 32: {
   3519 
   3520 
   3521 
   3522          const struct float32_vec src0 = {
   3523                _src[0].f32[0],
   3524                _src[0].f32[1],
   3525                _src[0].f32[2],
   3526             0,
   3527          };
   3528 
   3529          const struct float32_vec src1 = {
   3530                _src[1].f32[0],
   3531                _src[1].f32[1],
   3532                _src[1].f32[2],
   3533                _src[1].f32[3],
   3534          };
   3535 
   3536          struct float32_vec dst;
   3537 
   3538             dst.x = dst.y = dst.z = dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w;
   3539 
   3540                _dst_val.f32[0] = dst.x;
   3541                _dst_val.f32[1] = dst.y;
   3542                _dst_val.f32[2] = dst.z;
   3543                _dst_val.f32[3] = dst.w;
   3544 
   3545       break;
   3546    }
   3547    case 64: {
   3548 
   3549 
   3550 
   3551          const struct float64_vec src0 = {
   3552                _src[0].f64[0],
   3553                _src[0].f64[1],
   3554                _src[0].f64[2],
   3555             0,
   3556          };
   3557 
   3558          const struct float64_vec src1 = {
   3559                _src[1].f64[0],
   3560                _src[1].f64[1],
   3561                _src[1].f64[2],
   3562                _src[1].f64[3],
   3563          };
   3564 
   3565          struct float64_vec dst;
   3566 
   3567             dst.x = dst.y = dst.z = dst.w = src0.x * src1.x + src0.y * src1.y + src0.z * src1.z + src1.w;
   3568 
   3569                _dst_val.f64[0] = dst.x;
   3570                _dst_val.f64[1] = dst.y;
   3571                _dst_val.f64[2] = dst.z;
   3572                _dst_val.f64[3] = dst.w;
   3573 
   3574       break;
   3575    }
   3576 
   3577    default:
   3578       unreachable("unknown bit width");
   3579    }
   3580 
   3581    return _dst_val;
   3582 }
   3583 static nir_const_value
   3584 evaluate_feq(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3585                  MAYBE_UNUSED nir_const_value *_src)
   3586 {
   3587    nir_const_value _dst_val = { {0, } };
   3588 
   3589    switch (bit_size) {
   3590    case 32: {
   3591 
   3592 
   3593 
   3594          for (unsigned _i = 0; _i < num_components; _i++) {
   3595                   const float32_t src0 =
   3596                      _src[0].f32[_i];
   3597                   const float32_t src1 =
   3598                      _src[1].f32[_i];
   3599 
   3600                bool32_t dst = src0 == src1;
   3601 
   3602                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   3603          }
   3604 
   3605       break;
   3606    }
   3607    case 64: {
   3608 
   3609 
   3610 
   3611          for (unsigned _i = 0; _i < num_components; _i++) {
   3612                   const float64_t src0 =
   3613                      _src[0].f64[_i];
   3614                   const float64_t src1 =
   3615                      _src[1].f64[_i];
   3616 
   3617                bool32_t dst = src0 == src1;
   3618 
   3619                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   3620          }
   3621 
   3622       break;
   3623    }
   3624 
   3625    default:
   3626       unreachable("unknown bit width");
   3627    }
   3628 
   3629    return _dst_val;
   3630 }
   3631 static nir_const_value
   3632 evaluate_fexp2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3633                  MAYBE_UNUSED nir_const_value *_src)
   3634 {
   3635    nir_const_value _dst_val = { {0, } };
   3636 
   3637    switch (bit_size) {
   3638    case 32: {
   3639 
   3640 
   3641 
   3642          for (unsigned _i = 0; _i < num_components; _i++) {
   3643                   const float32_t src0 =
   3644                      _src[0].f32[_i];
   3645 
   3646                float32_t dst = exp2f(src0);
   3647 
   3648                _dst_val.f32[_i] = dst;
   3649          }
   3650 
   3651       break;
   3652    }
   3653    case 64: {
   3654 
   3655 
   3656 
   3657          for (unsigned _i = 0; _i < num_components; _i++) {
   3658                   const float64_t src0 =
   3659                      _src[0].f64[_i];
   3660 
   3661                float64_t dst = exp2f(src0);
   3662 
   3663                _dst_val.f64[_i] = dst;
   3664          }
   3665 
   3666       break;
   3667    }
   3668 
   3669    default:
   3670       unreachable("unknown bit width");
   3671    }
   3672 
   3673    return _dst_val;
   3674 }
   3675 static nir_const_value
   3676 evaluate_ffloor(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3677                  MAYBE_UNUSED nir_const_value *_src)
   3678 {
   3679    nir_const_value _dst_val = { {0, } };
   3680 
   3681    switch (bit_size) {
   3682    case 32: {
   3683 
   3684 
   3685 
   3686          for (unsigned _i = 0; _i < num_components; _i++) {
   3687                   const float32_t src0 =
   3688                      _src[0].f32[_i];
   3689 
   3690                float32_t dst = bit_size == 64 ? floor(src0) : floorf(src0);
   3691 
   3692                _dst_val.f32[_i] = dst;
   3693          }
   3694 
   3695       break;
   3696    }
   3697    case 64: {
   3698 
   3699 
   3700 
   3701          for (unsigned _i = 0; _i < num_components; _i++) {
   3702                   const float64_t src0 =
   3703                      _src[0].f64[_i];
   3704 
   3705                float64_t dst = bit_size == 64 ? floor(src0) : floorf(src0);
   3706 
   3707                _dst_val.f64[_i] = dst;
   3708          }
   3709 
   3710       break;
   3711    }
   3712 
   3713    default:
   3714       unreachable("unknown bit width");
   3715    }
   3716 
   3717    return _dst_val;
   3718 }
   3719 static nir_const_value
   3720 evaluate_ffma(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3721                  MAYBE_UNUSED nir_const_value *_src)
   3722 {
   3723    nir_const_value _dst_val = { {0, } };
   3724 
   3725    switch (bit_size) {
   3726    case 32: {
   3727 
   3728 
   3729 
   3730          for (unsigned _i = 0; _i < num_components; _i++) {
   3731                   const float32_t src0 =
   3732                      _src[0].f32[_i];
   3733                   const float32_t src1 =
   3734                      _src[1].f32[_i];
   3735                   const float32_t src2 =
   3736                      _src[2].f32[_i];
   3737 
   3738                float32_t dst = src0 * src1 + src2;
   3739 
   3740                _dst_val.f32[_i] = dst;
   3741          }
   3742 
   3743       break;
   3744    }
   3745    case 64: {
   3746 
   3747 
   3748 
   3749          for (unsigned _i = 0; _i < num_components; _i++) {
   3750                   const float64_t src0 =
   3751                      _src[0].f64[_i];
   3752                   const float64_t src1 =
   3753                      _src[1].f64[_i];
   3754                   const float64_t src2 =
   3755                      _src[2].f64[_i];
   3756 
   3757                float64_t dst = src0 * src1 + src2;
   3758 
   3759                _dst_val.f64[_i] = dst;
   3760          }
   3761 
   3762       break;
   3763    }
   3764 
   3765    default:
   3766       unreachable("unknown bit width");
   3767    }
   3768 
   3769    return _dst_val;
   3770 }
   3771 static nir_const_value
   3772 evaluate_ffract(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3773                  MAYBE_UNUSED nir_const_value *_src)
   3774 {
   3775    nir_const_value _dst_val = { {0, } };
   3776 
   3777    switch (bit_size) {
   3778    case 32: {
   3779 
   3780 
   3781 
   3782          for (unsigned _i = 0; _i < num_components; _i++) {
   3783                   const float32_t src0 =
   3784                      _src[0].f32[_i];
   3785 
   3786                float32_t dst = src0 - (bit_size == 64 ? floor(src0) : floorf(src0));
   3787 
   3788                _dst_val.f32[_i] = dst;
   3789          }
   3790 
   3791       break;
   3792    }
   3793    case 64: {
   3794 
   3795 
   3796 
   3797          for (unsigned _i = 0; _i < num_components; _i++) {
   3798                   const float64_t src0 =
   3799                      _src[0].f64[_i];
   3800 
   3801                float64_t dst = src0 - (bit_size == 64 ? floor(src0) : floorf(src0));
   3802 
   3803                _dst_val.f64[_i] = dst;
   3804          }
   3805 
   3806       break;
   3807    }
   3808 
   3809    default:
   3810       unreachable("unknown bit width");
   3811    }
   3812 
   3813    return _dst_val;
   3814 }
   3815 static nir_const_value
   3816 evaluate_fge(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3817                  MAYBE_UNUSED nir_const_value *_src)
   3818 {
   3819    nir_const_value _dst_val = { {0, } };
   3820 
   3821    switch (bit_size) {
   3822    case 32: {
   3823 
   3824 
   3825 
   3826          for (unsigned _i = 0; _i < num_components; _i++) {
   3827                   const float32_t src0 =
   3828                      _src[0].f32[_i];
   3829                   const float32_t src1 =
   3830                      _src[1].f32[_i];
   3831 
   3832                bool32_t dst = src0 >= src1;
   3833 
   3834                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   3835          }
   3836 
   3837       break;
   3838    }
   3839    case 64: {
   3840 
   3841 
   3842 
   3843          for (unsigned _i = 0; _i < num_components; _i++) {
   3844                   const float64_t src0 =
   3845                      _src[0].f64[_i];
   3846                   const float64_t src1 =
   3847                      _src[1].f64[_i];
   3848 
   3849                bool32_t dst = src0 >= src1;
   3850 
   3851                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   3852          }
   3853 
   3854       break;
   3855    }
   3856 
   3857    default:
   3858       unreachable("unknown bit width");
   3859    }
   3860 
   3861    return _dst_val;
   3862 }
   3863 static nir_const_value
   3864 evaluate_find_lsb(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3865                  MAYBE_UNUSED nir_const_value *_src)
   3866 {
   3867    nir_const_value _dst_val = { {0, } };
   3868 
   3869    switch (bit_size) {
   3870    case 32: {
   3871 
   3872 
   3873 
   3874          for (unsigned _i = 0; _i < num_components; _i++) {
   3875                   const int32_t src0 =
   3876                      _src[0].i32[_i];
   3877 
   3878                int32_t dst;
   3879 
   3880 
   3881 dst = -1;
   3882 for (unsigned bit = 0; bit < 32; bit++) {
   3883    if ((src0 >> bit) & 1) {
   3884       dst = bit;
   3885       break;
   3886    }
   3887 }
   3888 
   3889 
   3890                _dst_val.i32[_i] = dst;
   3891          }
   3892 
   3893       break;
   3894    }
   3895    case 64: {
   3896 
   3897 
   3898 
   3899          for (unsigned _i = 0; _i < num_components; _i++) {
   3900                   const int32_t src0 =
   3901                      _src[0].i32[_i];
   3902 
   3903                int32_t dst;
   3904 
   3905 
   3906 dst = -1;
   3907 for (unsigned bit = 0; bit < 32; bit++) {
   3908    if ((src0 >> bit) & 1) {
   3909       dst = bit;
   3910       break;
   3911    }
   3912 }
   3913 
   3914 
   3915                _dst_val.i32[_i] = dst;
   3916          }
   3917 
   3918       break;
   3919    }
   3920 
   3921    default:
   3922       unreachable("unknown bit width");
   3923    }
   3924 
   3925    return _dst_val;
   3926 }
   3927 static nir_const_value
   3928 evaluate_flog2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3929                  MAYBE_UNUSED nir_const_value *_src)
   3930 {
   3931    nir_const_value _dst_val = { {0, } };
   3932 
   3933    switch (bit_size) {
   3934    case 32: {
   3935 
   3936 
   3937 
   3938          for (unsigned _i = 0; _i < num_components; _i++) {
   3939                   const float32_t src0 =
   3940                      _src[0].f32[_i];
   3941 
   3942                float32_t dst = log2f(src0);
   3943 
   3944                _dst_val.f32[_i] = dst;
   3945          }
   3946 
   3947       break;
   3948    }
   3949    case 64: {
   3950 
   3951 
   3952 
   3953          for (unsigned _i = 0; _i < num_components; _i++) {
   3954                   const float64_t src0 =
   3955                      _src[0].f64[_i];
   3956 
   3957                float64_t dst = log2f(src0);
   3958 
   3959                _dst_val.f64[_i] = dst;
   3960          }
   3961 
   3962       break;
   3963    }
   3964 
   3965    default:
   3966       unreachable("unknown bit width");
   3967    }
   3968 
   3969    return _dst_val;
   3970 }
   3971 static nir_const_value
   3972 evaluate_flrp(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   3973                  MAYBE_UNUSED nir_const_value *_src)
   3974 {
   3975    nir_const_value _dst_val = { {0, } };
   3976 
   3977    switch (bit_size) {
   3978    case 32: {
   3979 
   3980 
   3981 
   3982          for (unsigned _i = 0; _i < num_components; _i++) {
   3983                   const float32_t src0 =
   3984                      _src[0].f32[_i];
   3985                   const float32_t src1 =
   3986                      _src[1].f32[_i];
   3987                   const float32_t src2 =
   3988                      _src[2].f32[_i];
   3989 
   3990                float32_t dst = src0 * (1 - src2) + src1 * src2;
   3991 
   3992                _dst_val.f32[_i] = dst;
   3993          }
   3994 
   3995       break;
   3996    }
   3997    case 64: {
   3998 
   3999 
   4000 
   4001          for (unsigned _i = 0; _i < num_components; _i++) {
   4002                   const float64_t src0 =
   4003                      _src[0].f64[_i];
   4004                   const float64_t src1 =
   4005                      _src[1].f64[_i];
   4006                   const float64_t src2 =
   4007                      _src[2].f64[_i];
   4008 
   4009                float64_t dst = src0 * (1 - src2) + src1 * src2;
   4010 
   4011                _dst_val.f64[_i] = dst;
   4012          }
   4013 
   4014       break;
   4015    }
   4016 
   4017    default:
   4018       unreachable("unknown bit width");
   4019    }
   4020 
   4021    return _dst_val;
   4022 }
   4023 static nir_const_value
   4024 evaluate_flt(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4025                  MAYBE_UNUSED nir_const_value *_src)
   4026 {
   4027    nir_const_value _dst_val = { {0, } };
   4028 
   4029    switch (bit_size) {
   4030    case 32: {
   4031 
   4032 
   4033 
   4034          for (unsigned _i = 0; _i < num_components; _i++) {
   4035                   const float32_t src0 =
   4036                      _src[0].f32[_i];
   4037                   const float32_t src1 =
   4038                      _src[1].f32[_i];
   4039 
   4040                bool32_t dst = src0 < src1;
   4041 
   4042                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   4043          }
   4044 
   4045       break;
   4046    }
   4047    case 64: {
   4048 
   4049 
   4050 
   4051          for (unsigned _i = 0; _i < num_components; _i++) {
   4052                   const float64_t src0 =
   4053                      _src[0].f64[_i];
   4054                   const float64_t src1 =
   4055                      _src[1].f64[_i];
   4056 
   4057                bool32_t dst = src0 < src1;
   4058 
   4059                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   4060          }
   4061 
   4062       break;
   4063    }
   4064 
   4065    default:
   4066       unreachable("unknown bit width");
   4067    }
   4068 
   4069    return _dst_val;
   4070 }
   4071 static nir_const_value
   4072 evaluate_fmax(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4073                  MAYBE_UNUSED nir_const_value *_src)
   4074 {
   4075    nir_const_value _dst_val = { {0, } };
   4076 
   4077    switch (bit_size) {
   4078    case 32: {
   4079 
   4080 
   4081 
   4082          for (unsigned _i = 0; _i < num_components; _i++) {
   4083                   const float32_t src0 =
   4084                      _src[0].f32[_i];
   4085                   const float32_t src1 =
   4086                      _src[1].f32[_i];
   4087 
   4088                float32_t dst = fmaxf(src0, src1);
   4089 
   4090                _dst_val.f32[_i] = dst;
   4091          }
   4092 
   4093       break;
   4094    }
   4095    case 64: {
   4096 
   4097 
   4098 
   4099          for (unsigned _i = 0; _i < num_components; _i++) {
   4100                   const float64_t src0 =
   4101                      _src[0].f64[_i];
   4102                   const float64_t src1 =
   4103                      _src[1].f64[_i];
   4104 
   4105                float64_t dst = fmaxf(src0, src1);
   4106 
   4107                _dst_val.f64[_i] = dst;
   4108          }
   4109 
   4110       break;
   4111    }
   4112 
   4113    default:
   4114       unreachable("unknown bit width");
   4115    }
   4116 
   4117    return _dst_val;
   4118 }
   4119 static nir_const_value
   4120 evaluate_fmin(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4121                  MAYBE_UNUSED nir_const_value *_src)
   4122 {
   4123    nir_const_value _dst_val = { {0, } };
   4124 
   4125    switch (bit_size) {
   4126    case 32: {
   4127 
   4128 
   4129 
   4130          for (unsigned _i = 0; _i < num_components; _i++) {
   4131                   const float32_t src0 =
   4132                      _src[0].f32[_i];
   4133                   const float32_t src1 =
   4134                      _src[1].f32[_i];
   4135 
   4136                float32_t dst = fminf(src0, src1);
   4137 
   4138                _dst_val.f32[_i] = dst;
   4139          }
   4140 
   4141       break;
   4142    }
   4143    case 64: {
   4144 
   4145 
   4146 
   4147          for (unsigned _i = 0; _i < num_components; _i++) {
   4148                   const float64_t src0 =
   4149                      _src[0].f64[_i];
   4150                   const float64_t src1 =
   4151                      _src[1].f64[_i];
   4152 
   4153                float64_t dst = fminf(src0, src1);
   4154 
   4155                _dst_val.f64[_i] = dst;
   4156          }
   4157 
   4158       break;
   4159    }
   4160 
   4161    default:
   4162       unreachable("unknown bit width");
   4163    }
   4164 
   4165    return _dst_val;
   4166 }
   4167 static nir_const_value
   4168 evaluate_fmod(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4169                  MAYBE_UNUSED nir_const_value *_src)
   4170 {
   4171    nir_const_value _dst_val = { {0, } };
   4172 
   4173    switch (bit_size) {
   4174    case 32: {
   4175 
   4176 
   4177 
   4178          for (unsigned _i = 0; _i < num_components; _i++) {
   4179                   const float32_t src0 =
   4180                      _src[0].f32[_i];
   4181                   const float32_t src1 =
   4182                      _src[1].f32[_i];
   4183 
   4184                float32_t dst = src0 - src1 * floorf(src0 / src1);
   4185 
   4186                _dst_val.f32[_i] = dst;
   4187          }
   4188 
   4189       break;
   4190    }
   4191    case 64: {
   4192 
   4193 
   4194 
   4195          for (unsigned _i = 0; _i < num_components; _i++) {
   4196                   const float64_t src0 =
   4197                      _src[0].f64[_i];
   4198                   const float64_t src1 =
   4199                      _src[1].f64[_i];
   4200 
   4201                float64_t dst = src0 - src1 * floorf(src0 / src1);
   4202 
   4203                _dst_val.f64[_i] = dst;
   4204          }
   4205 
   4206       break;
   4207    }
   4208 
   4209    default:
   4210       unreachable("unknown bit width");
   4211    }
   4212 
   4213    return _dst_val;
   4214 }
   4215 static nir_const_value
   4216 evaluate_fmov(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4217                  MAYBE_UNUSED nir_const_value *_src)
   4218 {
   4219    nir_const_value _dst_val = { {0, } };
   4220 
   4221    switch (bit_size) {
   4222    case 32: {
   4223 
   4224 
   4225 
   4226          for (unsigned _i = 0; _i < num_components; _i++) {
   4227                   const float32_t src0 =
   4228                      _src[0].f32[_i];
   4229 
   4230                float32_t dst = src0;
   4231 
   4232                _dst_val.f32[_i] = dst;
   4233          }
   4234 
   4235       break;
   4236    }
   4237    case 64: {
   4238 
   4239 
   4240 
   4241          for (unsigned _i = 0; _i < num_components; _i++) {
   4242                   const float64_t src0 =
   4243                      _src[0].f64[_i];
   4244 
   4245                float64_t dst = src0;
   4246 
   4247                _dst_val.f64[_i] = dst;
   4248          }
   4249 
   4250       break;
   4251    }
   4252 
   4253    default:
   4254       unreachable("unknown bit width");
   4255    }
   4256 
   4257    return _dst_val;
   4258 }
   4259 static nir_const_value
   4260 evaluate_fmul(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4261                  MAYBE_UNUSED nir_const_value *_src)
   4262 {
   4263    nir_const_value _dst_val = { {0, } };
   4264 
   4265    switch (bit_size) {
   4266    case 32: {
   4267 
   4268 
   4269 
   4270          for (unsigned _i = 0; _i < num_components; _i++) {
   4271                   const float32_t src0 =
   4272                      _src[0].f32[_i];
   4273                   const float32_t src1 =
   4274                      _src[1].f32[_i];
   4275 
   4276                float32_t dst = src0 * src1;
   4277 
   4278                _dst_val.f32[_i] = dst;
   4279          }
   4280 
   4281       break;
   4282    }
   4283    case 64: {
   4284 
   4285 
   4286 
   4287          for (unsigned _i = 0; _i < num_components; _i++) {
   4288                   const float64_t src0 =
   4289                      _src[0].f64[_i];
   4290                   const float64_t src1 =
   4291                      _src[1].f64[_i];
   4292 
   4293                float64_t dst = src0 * src1;
   4294 
   4295                _dst_val.f64[_i] = dst;
   4296          }
   4297 
   4298       break;
   4299    }
   4300 
   4301    default:
   4302       unreachable("unknown bit width");
   4303    }
   4304 
   4305    return _dst_val;
   4306 }
   4307 static nir_const_value
   4308 evaluate_fne(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4309                  MAYBE_UNUSED nir_const_value *_src)
   4310 {
   4311    nir_const_value _dst_val = { {0, } };
   4312 
   4313    switch (bit_size) {
   4314    case 32: {
   4315 
   4316 
   4317 
   4318          for (unsigned _i = 0; _i < num_components; _i++) {
   4319                   const float32_t src0 =
   4320                      _src[0].f32[_i];
   4321                   const float32_t src1 =
   4322                      _src[1].f32[_i];
   4323 
   4324                bool32_t dst = src0 != src1;
   4325 
   4326                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   4327          }
   4328 
   4329       break;
   4330    }
   4331    case 64: {
   4332 
   4333 
   4334 
   4335          for (unsigned _i = 0; _i < num_components; _i++) {
   4336                   const float64_t src0 =
   4337                      _src[0].f64[_i];
   4338                   const float64_t src1 =
   4339                      _src[1].f64[_i];
   4340 
   4341                bool32_t dst = src0 != src1;
   4342 
   4343                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   4344          }
   4345 
   4346       break;
   4347    }
   4348 
   4349    default:
   4350       unreachable("unknown bit width");
   4351    }
   4352 
   4353    return _dst_val;
   4354 }
   4355 static nir_const_value
   4356 evaluate_fneg(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4357                  MAYBE_UNUSED nir_const_value *_src)
   4358 {
   4359    nir_const_value _dst_val = { {0, } };
   4360 
   4361    switch (bit_size) {
   4362    case 32: {
   4363 
   4364 
   4365 
   4366          for (unsigned _i = 0; _i < num_components; _i++) {
   4367                   const float32_t src0 =
   4368                      _src[0].f32[_i];
   4369 
   4370                float32_t dst = -src0;
   4371 
   4372                _dst_val.f32[_i] = dst;
   4373          }
   4374 
   4375       break;
   4376    }
   4377    case 64: {
   4378 
   4379 
   4380 
   4381          for (unsigned _i = 0; _i < num_components; _i++) {
   4382                   const float64_t src0 =
   4383                      _src[0].f64[_i];
   4384 
   4385                float64_t dst = -src0;
   4386 
   4387                _dst_val.f64[_i] = dst;
   4388          }
   4389 
   4390       break;
   4391    }
   4392 
   4393    default:
   4394       unreachable("unknown bit width");
   4395    }
   4396 
   4397    return _dst_val;
   4398 }
   4399 static nir_const_value
   4400 evaluate_fnoise1_1(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4401                  MAYBE_UNUSED nir_const_value *_src)
   4402 {
   4403    nir_const_value _dst_val = { {0, } };
   4404 
   4405    switch (bit_size) {
   4406    case 32: {
   4407 
   4408 
   4409 
   4410          struct float32_vec dst;
   4411 
   4412             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4413 
   4414                _dst_val.f32[0] = dst.x;
   4415 
   4416       break;
   4417    }
   4418    case 64: {
   4419 
   4420 
   4421 
   4422          struct float64_vec dst;
   4423 
   4424             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4425 
   4426                _dst_val.f64[0] = dst.x;
   4427 
   4428       break;
   4429    }
   4430 
   4431    default:
   4432       unreachable("unknown bit width");
   4433    }
   4434 
   4435    return _dst_val;
   4436 }
   4437 static nir_const_value
   4438 evaluate_fnoise1_2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4439                  MAYBE_UNUSED nir_const_value *_src)
   4440 {
   4441    nir_const_value _dst_val = { {0, } };
   4442 
   4443    switch (bit_size) {
   4444    case 32: {
   4445 
   4446 
   4447 
   4448          struct float32_vec dst;
   4449 
   4450             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4451 
   4452                _dst_val.f32[0] = dst.x;
   4453 
   4454       break;
   4455    }
   4456    case 64: {
   4457 
   4458 
   4459 
   4460          struct float64_vec dst;
   4461 
   4462             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4463 
   4464                _dst_val.f64[0] = dst.x;
   4465 
   4466       break;
   4467    }
   4468 
   4469    default:
   4470       unreachable("unknown bit width");
   4471    }
   4472 
   4473    return _dst_val;
   4474 }
   4475 static nir_const_value
   4476 evaluate_fnoise1_3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4477                  MAYBE_UNUSED nir_const_value *_src)
   4478 {
   4479    nir_const_value _dst_val = { {0, } };
   4480 
   4481    switch (bit_size) {
   4482    case 32: {
   4483 
   4484 
   4485 
   4486          struct float32_vec dst;
   4487 
   4488             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4489 
   4490                _dst_val.f32[0] = dst.x;
   4491 
   4492       break;
   4493    }
   4494    case 64: {
   4495 
   4496 
   4497 
   4498          struct float64_vec dst;
   4499 
   4500             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4501 
   4502                _dst_val.f64[0] = dst.x;
   4503 
   4504       break;
   4505    }
   4506 
   4507    default:
   4508       unreachable("unknown bit width");
   4509    }
   4510 
   4511    return _dst_val;
   4512 }
   4513 static nir_const_value
   4514 evaluate_fnoise1_4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4515                  MAYBE_UNUSED nir_const_value *_src)
   4516 {
   4517    nir_const_value _dst_val = { {0, } };
   4518 
   4519    switch (bit_size) {
   4520    case 32: {
   4521 
   4522 
   4523 
   4524          struct float32_vec dst;
   4525 
   4526             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4527 
   4528                _dst_val.f32[0] = dst.x;
   4529 
   4530       break;
   4531    }
   4532    case 64: {
   4533 
   4534 
   4535 
   4536          struct float64_vec dst;
   4537 
   4538             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4539 
   4540                _dst_val.f64[0] = dst.x;
   4541 
   4542       break;
   4543    }
   4544 
   4545    default:
   4546       unreachable("unknown bit width");
   4547    }
   4548 
   4549    return _dst_val;
   4550 }
   4551 static nir_const_value
   4552 evaluate_fnoise2_1(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4553                  MAYBE_UNUSED nir_const_value *_src)
   4554 {
   4555    nir_const_value _dst_val = { {0, } };
   4556 
   4557    switch (bit_size) {
   4558    case 32: {
   4559 
   4560 
   4561 
   4562          struct float32_vec dst;
   4563 
   4564             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4565 
   4566                _dst_val.f32[0] = dst.x;
   4567                _dst_val.f32[1] = dst.y;
   4568 
   4569       break;
   4570    }
   4571    case 64: {
   4572 
   4573 
   4574 
   4575          struct float64_vec dst;
   4576 
   4577             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4578 
   4579                _dst_val.f64[0] = dst.x;
   4580                _dst_val.f64[1] = dst.y;
   4581 
   4582       break;
   4583    }
   4584 
   4585    default:
   4586       unreachable("unknown bit width");
   4587    }
   4588 
   4589    return _dst_val;
   4590 }
   4591 static nir_const_value
   4592 evaluate_fnoise2_2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4593                  MAYBE_UNUSED nir_const_value *_src)
   4594 {
   4595    nir_const_value _dst_val = { {0, } };
   4596 
   4597    switch (bit_size) {
   4598    case 32: {
   4599 
   4600 
   4601 
   4602          struct float32_vec dst;
   4603 
   4604             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4605 
   4606                _dst_val.f32[0] = dst.x;
   4607                _dst_val.f32[1] = dst.y;
   4608 
   4609       break;
   4610    }
   4611    case 64: {
   4612 
   4613 
   4614 
   4615          struct float64_vec dst;
   4616 
   4617             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4618 
   4619                _dst_val.f64[0] = dst.x;
   4620                _dst_val.f64[1] = dst.y;
   4621 
   4622       break;
   4623    }
   4624 
   4625    default:
   4626       unreachable("unknown bit width");
   4627    }
   4628 
   4629    return _dst_val;
   4630 }
   4631 static nir_const_value
   4632 evaluate_fnoise2_3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4633                  MAYBE_UNUSED nir_const_value *_src)
   4634 {
   4635    nir_const_value _dst_val = { {0, } };
   4636 
   4637    switch (bit_size) {
   4638    case 32: {
   4639 
   4640 
   4641 
   4642          struct float32_vec dst;
   4643 
   4644             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4645 
   4646                _dst_val.f32[0] = dst.x;
   4647                _dst_val.f32[1] = dst.y;
   4648 
   4649       break;
   4650    }
   4651    case 64: {
   4652 
   4653 
   4654 
   4655          struct float64_vec dst;
   4656 
   4657             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4658 
   4659                _dst_val.f64[0] = dst.x;
   4660                _dst_val.f64[1] = dst.y;
   4661 
   4662       break;
   4663    }
   4664 
   4665    default:
   4666       unreachable("unknown bit width");
   4667    }
   4668 
   4669    return _dst_val;
   4670 }
   4671 static nir_const_value
   4672 evaluate_fnoise2_4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4673                  MAYBE_UNUSED nir_const_value *_src)
   4674 {
   4675    nir_const_value _dst_val = { {0, } };
   4676 
   4677    switch (bit_size) {
   4678    case 32: {
   4679 
   4680 
   4681 
   4682          struct float32_vec dst;
   4683 
   4684             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4685 
   4686                _dst_val.f32[0] = dst.x;
   4687                _dst_val.f32[1] = dst.y;
   4688 
   4689       break;
   4690    }
   4691    case 64: {
   4692 
   4693 
   4694 
   4695          struct float64_vec dst;
   4696 
   4697             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4698 
   4699                _dst_val.f64[0] = dst.x;
   4700                _dst_val.f64[1] = dst.y;
   4701 
   4702       break;
   4703    }
   4704 
   4705    default:
   4706       unreachable("unknown bit width");
   4707    }
   4708 
   4709    return _dst_val;
   4710 }
   4711 static nir_const_value
   4712 evaluate_fnoise3_1(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4713                  MAYBE_UNUSED nir_const_value *_src)
   4714 {
   4715    nir_const_value _dst_val = { {0, } };
   4716 
   4717    switch (bit_size) {
   4718    case 32: {
   4719 
   4720 
   4721 
   4722          struct float32_vec dst;
   4723 
   4724             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4725 
   4726                _dst_val.f32[0] = dst.x;
   4727                _dst_val.f32[1] = dst.y;
   4728                _dst_val.f32[2] = dst.z;
   4729 
   4730       break;
   4731    }
   4732    case 64: {
   4733 
   4734 
   4735 
   4736          struct float64_vec dst;
   4737 
   4738             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4739 
   4740                _dst_val.f64[0] = dst.x;
   4741                _dst_val.f64[1] = dst.y;
   4742                _dst_val.f64[2] = dst.z;
   4743 
   4744       break;
   4745    }
   4746 
   4747    default:
   4748       unreachable("unknown bit width");
   4749    }
   4750 
   4751    return _dst_val;
   4752 }
   4753 static nir_const_value
   4754 evaluate_fnoise3_2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4755                  MAYBE_UNUSED nir_const_value *_src)
   4756 {
   4757    nir_const_value _dst_val = { {0, } };
   4758 
   4759    switch (bit_size) {
   4760    case 32: {
   4761 
   4762 
   4763 
   4764          struct float32_vec dst;
   4765 
   4766             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4767 
   4768                _dst_val.f32[0] = dst.x;
   4769                _dst_val.f32[1] = dst.y;
   4770                _dst_val.f32[2] = dst.z;
   4771 
   4772       break;
   4773    }
   4774    case 64: {
   4775 
   4776 
   4777 
   4778          struct float64_vec dst;
   4779 
   4780             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4781 
   4782                _dst_val.f64[0] = dst.x;
   4783                _dst_val.f64[1] = dst.y;
   4784                _dst_val.f64[2] = dst.z;
   4785 
   4786       break;
   4787    }
   4788 
   4789    default:
   4790       unreachable("unknown bit width");
   4791    }
   4792 
   4793    return _dst_val;
   4794 }
   4795 static nir_const_value
   4796 evaluate_fnoise3_3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4797                  MAYBE_UNUSED nir_const_value *_src)
   4798 {
   4799    nir_const_value _dst_val = { {0, } };
   4800 
   4801    switch (bit_size) {
   4802    case 32: {
   4803 
   4804 
   4805 
   4806          struct float32_vec dst;
   4807 
   4808             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4809 
   4810                _dst_val.f32[0] = dst.x;
   4811                _dst_val.f32[1] = dst.y;
   4812                _dst_val.f32[2] = dst.z;
   4813 
   4814       break;
   4815    }
   4816    case 64: {
   4817 
   4818 
   4819 
   4820          struct float64_vec dst;
   4821 
   4822             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4823 
   4824                _dst_val.f64[0] = dst.x;
   4825                _dst_val.f64[1] = dst.y;
   4826                _dst_val.f64[2] = dst.z;
   4827 
   4828       break;
   4829    }
   4830 
   4831    default:
   4832       unreachable("unknown bit width");
   4833    }
   4834 
   4835    return _dst_val;
   4836 }
   4837 static nir_const_value
   4838 evaluate_fnoise3_4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4839                  MAYBE_UNUSED nir_const_value *_src)
   4840 {
   4841    nir_const_value _dst_val = { {0, } };
   4842 
   4843    switch (bit_size) {
   4844    case 32: {
   4845 
   4846 
   4847 
   4848          struct float32_vec dst;
   4849 
   4850             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4851 
   4852                _dst_val.f32[0] = dst.x;
   4853                _dst_val.f32[1] = dst.y;
   4854                _dst_val.f32[2] = dst.z;
   4855 
   4856       break;
   4857    }
   4858    case 64: {
   4859 
   4860 
   4861 
   4862          struct float64_vec dst;
   4863 
   4864             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4865 
   4866                _dst_val.f64[0] = dst.x;
   4867                _dst_val.f64[1] = dst.y;
   4868                _dst_val.f64[2] = dst.z;
   4869 
   4870       break;
   4871    }
   4872 
   4873    default:
   4874       unreachable("unknown bit width");
   4875    }
   4876 
   4877    return _dst_val;
   4878 }
   4879 static nir_const_value
   4880 evaluate_fnoise4_1(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4881                  MAYBE_UNUSED nir_const_value *_src)
   4882 {
   4883    nir_const_value _dst_val = { {0, } };
   4884 
   4885    switch (bit_size) {
   4886    case 32: {
   4887 
   4888 
   4889 
   4890          struct float32_vec dst;
   4891 
   4892             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4893 
   4894                _dst_val.f32[0] = dst.x;
   4895                _dst_val.f32[1] = dst.y;
   4896                _dst_val.f32[2] = dst.z;
   4897                _dst_val.f32[3] = dst.w;
   4898 
   4899       break;
   4900    }
   4901    case 64: {
   4902 
   4903 
   4904 
   4905          struct float64_vec dst;
   4906 
   4907             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4908 
   4909                _dst_val.f64[0] = dst.x;
   4910                _dst_val.f64[1] = dst.y;
   4911                _dst_val.f64[2] = dst.z;
   4912                _dst_val.f64[3] = dst.w;
   4913 
   4914       break;
   4915    }
   4916 
   4917    default:
   4918       unreachable("unknown bit width");
   4919    }
   4920 
   4921    return _dst_val;
   4922 }
   4923 static nir_const_value
   4924 evaluate_fnoise4_2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4925                  MAYBE_UNUSED nir_const_value *_src)
   4926 {
   4927    nir_const_value _dst_val = { {0, } };
   4928 
   4929    switch (bit_size) {
   4930    case 32: {
   4931 
   4932 
   4933 
   4934          struct float32_vec dst;
   4935 
   4936             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4937 
   4938                _dst_val.f32[0] = dst.x;
   4939                _dst_val.f32[1] = dst.y;
   4940                _dst_val.f32[2] = dst.z;
   4941                _dst_val.f32[3] = dst.w;
   4942 
   4943       break;
   4944    }
   4945    case 64: {
   4946 
   4947 
   4948 
   4949          struct float64_vec dst;
   4950 
   4951             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4952 
   4953                _dst_val.f64[0] = dst.x;
   4954                _dst_val.f64[1] = dst.y;
   4955                _dst_val.f64[2] = dst.z;
   4956                _dst_val.f64[3] = dst.w;
   4957 
   4958       break;
   4959    }
   4960 
   4961    default:
   4962       unreachable("unknown bit width");
   4963    }
   4964 
   4965    return _dst_val;
   4966 }
   4967 static nir_const_value
   4968 evaluate_fnoise4_3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   4969                  MAYBE_UNUSED nir_const_value *_src)
   4970 {
   4971    nir_const_value _dst_val = { {0, } };
   4972 
   4973    switch (bit_size) {
   4974    case 32: {
   4975 
   4976 
   4977 
   4978          struct float32_vec dst;
   4979 
   4980             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4981 
   4982                _dst_val.f32[0] = dst.x;
   4983                _dst_val.f32[1] = dst.y;
   4984                _dst_val.f32[2] = dst.z;
   4985                _dst_val.f32[3] = dst.w;
   4986 
   4987       break;
   4988    }
   4989    case 64: {
   4990 
   4991 
   4992 
   4993          struct float64_vec dst;
   4994 
   4995             dst.x = dst.y = dst.z = dst.w = 0.0f;
   4996 
   4997                _dst_val.f64[0] = dst.x;
   4998                _dst_val.f64[1] = dst.y;
   4999                _dst_val.f64[2] = dst.z;
   5000                _dst_val.f64[3] = dst.w;
   5001 
   5002       break;
   5003    }
   5004 
   5005    default:
   5006       unreachable("unknown bit width");
   5007    }
   5008 
   5009    return _dst_val;
   5010 }
   5011 static nir_const_value
   5012 evaluate_fnoise4_4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5013                  MAYBE_UNUSED nir_const_value *_src)
   5014 {
   5015    nir_const_value _dst_val = { {0, } };
   5016 
   5017    switch (bit_size) {
   5018    case 32: {
   5019 
   5020 
   5021 
   5022          struct float32_vec dst;
   5023 
   5024             dst.x = dst.y = dst.z = dst.w = 0.0f;
   5025 
   5026                _dst_val.f32[0] = dst.x;
   5027                _dst_val.f32[1] = dst.y;
   5028                _dst_val.f32[2] = dst.z;
   5029                _dst_val.f32[3] = dst.w;
   5030 
   5031       break;
   5032    }
   5033    case 64: {
   5034 
   5035 
   5036 
   5037          struct float64_vec dst;
   5038 
   5039             dst.x = dst.y = dst.z = dst.w = 0.0f;
   5040 
   5041                _dst_val.f64[0] = dst.x;
   5042                _dst_val.f64[1] = dst.y;
   5043                _dst_val.f64[2] = dst.z;
   5044                _dst_val.f64[3] = dst.w;
   5045 
   5046       break;
   5047    }
   5048 
   5049    default:
   5050       unreachable("unknown bit width");
   5051    }
   5052 
   5053    return _dst_val;
   5054 }
   5055 static nir_const_value
   5056 evaluate_fnot(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5057                  MAYBE_UNUSED nir_const_value *_src)
   5058 {
   5059    nir_const_value _dst_val = { {0, } };
   5060 
   5061    switch (bit_size) {
   5062    case 32: {
   5063 
   5064 
   5065 
   5066          for (unsigned _i = 0; _i < num_components; _i++) {
   5067                   const float32_t src0 =
   5068                      _src[0].f32[_i];
   5069 
   5070                float32_t dst = bit_size == 64 ? ((src0 == 0.0) ? 1.0 : 0.0f) : ((src0 == 0.0f) ? 1.0f : 0.0f);
   5071 
   5072                _dst_val.f32[_i] = dst;
   5073          }
   5074 
   5075       break;
   5076    }
   5077    case 64: {
   5078 
   5079 
   5080 
   5081          for (unsigned _i = 0; _i < num_components; _i++) {
   5082                   const float64_t src0 =
   5083                      _src[0].f64[_i];
   5084 
   5085                float64_t dst = bit_size == 64 ? ((src0 == 0.0) ? 1.0 : 0.0f) : ((src0 == 0.0f) ? 1.0f : 0.0f);
   5086 
   5087                _dst_val.f64[_i] = dst;
   5088          }
   5089 
   5090       break;
   5091    }
   5092 
   5093    default:
   5094       unreachable("unknown bit width");
   5095    }
   5096 
   5097    return _dst_val;
   5098 }
   5099 static nir_const_value
   5100 evaluate_for(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5101                  MAYBE_UNUSED nir_const_value *_src)
   5102 {
   5103    nir_const_value _dst_val = { {0, } };
   5104 
   5105    switch (bit_size) {
   5106    case 32: {
   5107 
   5108 
   5109 
   5110          for (unsigned _i = 0; _i < num_components; _i++) {
   5111                   const float32_t src0 =
   5112                      _src[0].f32[_i];
   5113                   const float32_t src1 =
   5114                      _src[1].f32[_i];
   5115 
   5116                float32_t dst = ((src0 != 0.0f) || (src1 != 0.0f)) ? 1.0f : 0.0f;
   5117 
   5118                _dst_val.f32[_i] = dst;
   5119          }
   5120 
   5121       break;
   5122    }
   5123    case 64: {
   5124 
   5125 
   5126 
   5127          for (unsigned _i = 0; _i < num_components; _i++) {
   5128                   const float32_t src0 =
   5129                      _src[0].f32[_i];
   5130                   const float32_t src1 =
   5131                      _src[1].f32[_i];
   5132 
   5133                float32_t dst = ((src0 != 0.0f) || (src1 != 0.0f)) ? 1.0f : 0.0f;
   5134 
   5135                _dst_val.f32[_i] = dst;
   5136          }
   5137 
   5138       break;
   5139    }
   5140 
   5141    default:
   5142       unreachable("unknown bit width");
   5143    }
   5144 
   5145    return _dst_val;
   5146 }
   5147 static nir_const_value
   5148 evaluate_fpow(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5149                  MAYBE_UNUSED nir_const_value *_src)
   5150 {
   5151    nir_const_value _dst_val = { {0, } };
   5152 
   5153    switch (bit_size) {
   5154    case 32: {
   5155 
   5156 
   5157 
   5158          for (unsigned _i = 0; _i < num_components; _i++) {
   5159                   const float32_t src0 =
   5160                      _src[0].f32[_i];
   5161                   const float32_t src1 =
   5162                      _src[1].f32[_i];
   5163 
   5164                float32_t dst = bit_size == 64 ? powf(src0, src1) : pow(src0, src1);
   5165 
   5166                _dst_val.f32[_i] = dst;
   5167          }
   5168 
   5169       break;
   5170    }
   5171    case 64: {
   5172 
   5173 
   5174 
   5175          for (unsigned _i = 0; _i < num_components; _i++) {
   5176                   const float64_t src0 =
   5177                      _src[0].f64[_i];
   5178                   const float64_t src1 =
   5179                      _src[1].f64[_i];
   5180 
   5181                float64_t dst = bit_size == 64 ? powf(src0, src1) : pow(src0, src1);
   5182 
   5183                _dst_val.f64[_i] = dst;
   5184          }
   5185 
   5186       break;
   5187    }
   5188 
   5189    default:
   5190       unreachable("unknown bit width");
   5191    }
   5192 
   5193    return _dst_val;
   5194 }
   5195 static nir_const_value
   5196 evaluate_fquantize2f16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5197                  MAYBE_UNUSED nir_const_value *_src)
   5198 {
   5199    nir_const_value _dst_val = { {0, } };
   5200 
   5201    switch (bit_size) {
   5202    case 32: {
   5203 
   5204 
   5205 
   5206          for (unsigned _i = 0; _i < num_components; _i++) {
   5207                   const float32_t src0 =
   5208                      _src[0].f32[_i];
   5209 
   5210                float32_t dst = (fabs(src0) < ldexpf(1.0, -14)) ? copysignf(0.0f, src0) : _mesa_half_to_float(_mesa_float_to_half(src0));
   5211 
   5212                _dst_val.f32[_i] = dst;
   5213          }
   5214 
   5215       break;
   5216    }
   5217    case 64: {
   5218 
   5219 
   5220 
   5221          for (unsigned _i = 0; _i < num_components; _i++) {
   5222                   const float64_t src0 =
   5223                      _src[0].f64[_i];
   5224 
   5225                float64_t dst = (fabs(src0) < ldexpf(1.0, -14)) ? copysignf(0.0f, src0) : _mesa_half_to_float(_mesa_float_to_half(src0));
   5226 
   5227                _dst_val.f64[_i] = dst;
   5228          }
   5229 
   5230       break;
   5231    }
   5232 
   5233    default:
   5234       unreachable("unknown bit width");
   5235    }
   5236 
   5237    return _dst_val;
   5238 }
   5239 static nir_const_value
   5240 evaluate_frcp(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5241                  MAYBE_UNUSED nir_const_value *_src)
   5242 {
   5243    nir_const_value _dst_val = { {0, } };
   5244 
   5245    switch (bit_size) {
   5246    case 32: {
   5247 
   5248 
   5249 
   5250          for (unsigned _i = 0; _i < num_components; _i++) {
   5251                   const float32_t src0 =
   5252                      _src[0].f32[_i];
   5253 
   5254                float32_t dst = bit_size == 64 ? 1.0 / src0 : 1.0f / src0;
   5255 
   5256                _dst_val.f32[_i] = dst;
   5257          }
   5258 
   5259       break;
   5260    }
   5261    case 64: {
   5262 
   5263 
   5264 
   5265          for (unsigned _i = 0; _i < num_components; _i++) {
   5266                   const float64_t src0 =
   5267                      _src[0].f64[_i];
   5268 
   5269                float64_t dst = bit_size == 64 ? 1.0 / src0 : 1.0f / src0;
   5270 
   5271                _dst_val.f64[_i] = dst;
   5272          }
   5273 
   5274       break;
   5275    }
   5276 
   5277    default:
   5278       unreachable("unknown bit width");
   5279    }
   5280 
   5281    return _dst_val;
   5282 }
   5283 static nir_const_value
   5284 evaluate_frem(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5285                  MAYBE_UNUSED nir_const_value *_src)
   5286 {
   5287    nir_const_value _dst_val = { {0, } };
   5288 
   5289    switch (bit_size) {
   5290    case 32: {
   5291 
   5292 
   5293 
   5294          for (unsigned _i = 0; _i < num_components; _i++) {
   5295                   const float32_t src0 =
   5296                      _src[0].f32[_i];
   5297                   const float32_t src1 =
   5298                      _src[1].f32[_i];
   5299 
   5300                float32_t dst = src0 - src1 * truncf(src0 / src1);
   5301 
   5302                _dst_val.f32[_i] = dst;
   5303          }
   5304 
   5305       break;
   5306    }
   5307    case 64: {
   5308 
   5309 
   5310 
   5311          for (unsigned _i = 0; _i < num_components; _i++) {
   5312                   const float64_t src0 =
   5313                      _src[0].f64[_i];
   5314                   const float64_t src1 =
   5315                      _src[1].f64[_i];
   5316 
   5317                float64_t dst = src0 - src1 * truncf(src0 / src1);
   5318 
   5319                _dst_val.f64[_i] = dst;
   5320          }
   5321 
   5322       break;
   5323    }
   5324 
   5325    default:
   5326       unreachable("unknown bit width");
   5327    }
   5328 
   5329    return _dst_val;
   5330 }
   5331 static nir_const_value
   5332 evaluate_fround_even(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5333                  MAYBE_UNUSED nir_const_value *_src)
   5334 {
   5335    nir_const_value _dst_val = { {0, } };
   5336 
   5337    switch (bit_size) {
   5338    case 32: {
   5339 
   5340 
   5341 
   5342          for (unsigned _i = 0; _i < num_components; _i++) {
   5343                   const float32_t src0 =
   5344                      _src[0].f32[_i];
   5345 
   5346                float32_t dst = bit_size == 64 ? _mesa_roundeven(src0) : _mesa_roundevenf(src0);
   5347 
   5348                _dst_val.f32[_i] = dst;
   5349          }
   5350 
   5351       break;
   5352    }
   5353    case 64: {
   5354 
   5355 
   5356 
   5357          for (unsigned _i = 0; _i < num_components; _i++) {
   5358                   const float64_t src0 =
   5359                      _src[0].f64[_i];
   5360 
   5361                float64_t dst = bit_size == 64 ? _mesa_roundeven(src0) : _mesa_roundevenf(src0);
   5362 
   5363                _dst_val.f64[_i] = dst;
   5364          }
   5365 
   5366       break;
   5367    }
   5368 
   5369    default:
   5370       unreachable("unknown bit width");
   5371    }
   5372 
   5373    return _dst_val;
   5374 }
   5375 static nir_const_value
   5376 evaluate_frsq(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5377                  MAYBE_UNUSED nir_const_value *_src)
   5378 {
   5379    nir_const_value _dst_val = { {0, } };
   5380 
   5381    switch (bit_size) {
   5382    case 32: {
   5383 
   5384 
   5385 
   5386          for (unsigned _i = 0; _i < num_components; _i++) {
   5387                   const float32_t src0 =
   5388                      _src[0].f32[_i];
   5389 
   5390                float32_t dst = bit_size == 64 ? 1.0 / sqrt(src0) : 1.0f / sqrtf(src0);
   5391 
   5392                _dst_val.f32[_i] = dst;
   5393          }
   5394 
   5395       break;
   5396    }
   5397    case 64: {
   5398 
   5399 
   5400 
   5401          for (unsigned _i = 0; _i < num_components; _i++) {
   5402                   const float64_t src0 =
   5403                      _src[0].f64[_i];
   5404 
   5405                float64_t dst = bit_size == 64 ? 1.0 / sqrt(src0) : 1.0f / sqrtf(src0);
   5406 
   5407                _dst_val.f64[_i] = dst;
   5408          }
   5409 
   5410       break;
   5411    }
   5412 
   5413    default:
   5414       unreachable("unknown bit width");
   5415    }
   5416 
   5417    return _dst_val;
   5418 }
   5419 static nir_const_value
   5420 evaluate_fsat(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5421                  MAYBE_UNUSED nir_const_value *_src)
   5422 {
   5423    nir_const_value _dst_val = { {0, } };
   5424 
   5425    switch (bit_size) {
   5426    case 32: {
   5427 
   5428 
   5429 
   5430          for (unsigned _i = 0; _i < num_components; _i++) {
   5431                   const float32_t src0 =
   5432                      _src[0].f32[_i];
   5433 
   5434                float32_t dst = bit_size == 64 ? ((src0 > 1.0) ? 1.0 : ((src0 <= 0.0) ? 0.0 : src0)) : ((src0 > 1.0f) ? 1.0f : ((src0 <= 0.0f) ? 0.0f : src0));
   5435 
   5436                _dst_val.f32[_i] = dst;
   5437          }
   5438 
   5439       break;
   5440    }
   5441    case 64: {
   5442 
   5443 
   5444 
   5445          for (unsigned _i = 0; _i < num_components; _i++) {
   5446                   const float64_t src0 =
   5447                      _src[0].f64[_i];
   5448 
   5449                float64_t dst = bit_size == 64 ? ((src0 > 1.0) ? 1.0 : ((src0 <= 0.0) ? 0.0 : src0)) : ((src0 > 1.0f) ? 1.0f : ((src0 <= 0.0f) ? 0.0f : src0));
   5450 
   5451                _dst_val.f64[_i] = dst;
   5452          }
   5453 
   5454       break;
   5455    }
   5456 
   5457    default:
   5458       unreachable("unknown bit width");
   5459    }
   5460 
   5461    return _dst_val;
   5462 }
   5463 static nir_const_value
   5464 evaluate_fsign(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5465                  MAYBE_UNUSED nir_const_value *_src)
   5466 {
   5467    nir_const_value _dst_val = { {0, } };
   5468 
   5469    switch (bit_size) {
   5470    case 32: {
   5471 
   5472 
   5473 
   5474          for (unsigned _i = 0; _i < num_components; _i++) {
   5475                   const float32_t src0 =
   5476                      _src[0].f32[_i];
   5477 
   5478                float32_t dst = bit_size == 64 ? ((src0 == 0.0) ? 0.0 : ((src0 > 0.0) ? 1.0 : -1.0)) : ((src0 == 0.0f) ? 0.0f : ((src0 > 0.0f) ? 1.0f : -1.0f));
   5479 
   5480                _dst_val.f32[_i] = dst;
   5481          }
   5482 
   5483       break;
   5484    }
   5485    case 64: {
   5486 
   5487 
   5488 
   5489          for (unsigned _i = 0; _i < num_components; _i++) {
   5490                   const float64_t src0 =
   5491                      _src[0].f64[_i];
   5492 
   5493                float64_t dst = bit_size == 64 ? ((src0 == 0.0) ? 0.0 : ((src0 > 0.0) ? 1.0 : -1.0)) : ((src0 == 0.0f) ? 0.0f : ((src0 > 0.0f) ? 1.0f : -1.0f));
   5494 
   5495                _dst_val.f64[_i] = dst;
   5496          }
   5497 
   5498       break;
   5499    }
   5500 
   5501    default:
   5502       unreachable("unknown bit width");
   5503    }
   5504 
   5505    return _dst_val;
   5506 }
   5507 static nir_const_value
   5508 evaluate_fsin(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5509                  MAYBE_UNUSED nir_const_value *_src)
   5510 {
   5511    nir_const_value _dst_val = { {0, } };
   5512 
   5513    switch (bit_size) {
   5514    case 32: {
   5515 
   5516 
   5517 
   5518          for (unsigned _i = 0; _i < num_components; _i++) {
   5519                   const float32_t src0 =
   5520                      _src[0].f32[_i];
   5521 
   5522                float32_t dst = bit_size == 64 ? sin(src0) : sinf(src0);
   5523 
   5524                _dst_val.f32[_i] = dst;
   5525          }
   5526 
   5527       break;
   5528    }
   5529    case 64: {
   5530 
   5531 
   5532 
   5533          for (unsigned _i = 0; _i < num_components; _i++) {
   5534                   const float64_t src0 =
   5535                      _src[0].f64[_i];
   5536 
   5537                float64_t dst = bit_size == 64 ? sin(src0) : sinf(src0);
   5538 
   5539                _dst_val.f64[_i] = dst;
   5540          }
   5541 
   5542       break;
   5543    }
   5544 
   5545    default:
   5546       unreachable("unknown bit width");
   5547    }
   5548 
   5549    return _dst_val;
   5550 }
   5551 static nir_const_value
   5552 evaluate_fsqrt(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5553                  MAYBE_UNUSED nir_const_value *_src)
   5554 {
   5555    nir_const_value _dst_val = { {0, } };
   5556 
   5557    switch (bit_size) {
   5558    case 32: {
   5559 
   5560 
   5561 
   5562          for (unsigned _i = 0; _i < num_components; _i++) {
   5563                   const float32_t src0 =
   5564                      _src[0].f32[_i];
   5565 
   5566                float32_t dst = bit_size == 64 ? sqrt(src0) : sqrtf(src0);
   5567 
   5568                _dst_val.f32[_i] = dst;
   5569          }
   5570 
   5571       break;
   5572    }
   5573    case 64: {
   5574 
   5575 
   5576 
   5577          for (unsigned _i = 0; _i < num_components; _i++) {
   5578                   const float64_t src0 =
   5579                      _src[0].f64[_i];
   5580 
   5581                float64_t dst = bit_size == 64 ? sqrt(src0) : sqrtf(src0);
   5582 
   5583                _dst_val.f64[_i] = dst;
   5584          }
   5585 
   5586       break;
   5587    }
   5588 
   5589    default:
   5590       unreachable("unknown bit width");
   5591    }
   5592 
   5593    return _dst_val;
   5594 }
   5595 static nir_const_value
   5596 evaluate_fsub(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5597                  MAYBE_UNUSED nir_const_value *_src)
   5598 {
   5599    nir_const_value _dst_val = { {0, } };
   5600 
   5601    switch (bit_size) {
   5602    case 32: {
   5603 
   5604 
   5605 
   5606          for (unsigned _i = 0; _i < num_components; _i++) {
   5607                   const float32_t src0 =
   5608                      _src[0].f32[_i];
   5609                   const float32_t src1 =
   5610                      _src[1].f32[_i];
   5611 
   5612                float32_t dst = src0 - src1;
   5613 
   5614                _dst_val.f32[_i] = dst;
   5615          }
   5616 
   5617       break;
   5618    }
   5619    case 64: {
   5620 
   5621 
   5622 
   5623          for (unsigned _i = 0; _i < num_components; _i++) {
   5624                   const float64_t src0 =
   5625                      _src[0].f64[_i];
   5626                   const float64_t src1 =
   5627                      _src[1].f64[_i];
   5628 
   5629                float64_t dst = src0 - src1;
   5630 
   5631                _dst_val.f64[_i] = dst;
   5632          }
   5633 
   5634       break;
   5635    }
   5636 
   5637    default:
   5638       unreachable("unknown bit width");
   5639    }
   5640 
   5641    return _dst_val;
   5642 }
   5643 static nir_const_value
   5644 evaluate_ftrunc(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5645                  MAYBE_UNUSED nir_const_value *_src)
   5646 {
   5647    nir_const_value _dst_val = { {0, } };
   5648 
   5649    switch (bit_size) {
   5650    case 32: {
   5651 
   5652 
   5653 
   5654          for (unsigned _i = 0; _i < num_components; _i++) {
   5655                   const float32_t src0 =
   5656                      _src[0].f32[_i];
   5657 
   5658                float32_t dst = bit_size == 64 ? trunc(src0) : truncf(src0);
   5659 
   5660                _dst_val.f32[_i] = dst;
   5661          }
   5662 
   5663       break;
   5664    }
   5665    case 64: {
   5666 
   5667 
   5668 
   5669          for (unsigned _i = 0; _i < num_components; _i++) {
   5670                   const float64_t src0 =
   5671                      _src[0].f64[_i];
   5672 
   5673                float64_t dst = bit_size == 64 ? trunc(src0) : truncf(src0);
   5674 
   5675                _dst_val.f64[_i] = dst;
   5676          }
   5677 
   5678       break;
   5679    }
   5680 
   5681    default:
   5682       unreachable("unknown bit width");
   5683    }
   5684 
   5685    return _dst_val;
   5686 }
   5687 static nir_const_value
   5688 evaluate_fxor(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5689                  MAYBE_UNUSED nir_const_value *_src)
   5690 {
   5691    nir_const_value _dst_val = { {0, } };
   5692 
   5693    switch (bit_size) {
   5694    case 32: {
   5695 
   5696 
   5697 
   5698          for (unsigned _i = 0; _i < num_components; _i++) {
   5699                   const float32_t src0 =
   5700                      _src[0].f32[_i];
   5701                   const float32_t src1 =
   5702                      _src[1].f32[_i];
   5703 
   5704                float32_t dst = (src0 != 0.0f && src1 == 0.0f) || (src0 == 0.0f && src1 != 0.0f) ? 1.0f : 0.0f;
   5705 
   5706                _dst_val.f32[_i] = dst;
   5707          }
   5708 
   5709       break;
   5710    }
   5711    case 64: {
   5712 
   5713 
   5714 
   5715          for (unsigned _i = 0; _i < num_components; _i++) {
   5716                   const float32_t src0 =
   5717                      _src[0].f32[_i];
   5718                   const float32_t src1 =
   5719                      _src[1].f32[_i];
   5720 
   5721                float32_t dst = (src0 != 0.0f && src1 == 0.0f) || (src0 == 0.0f && src1 != 0.0f) ? 1.0f : 0.0f;
   5722 
   5723                _dst_val.f32[_i] = dst;
   5724          }
   5725 
   5726       break;
   5727    }
   5728 
   5729    default:
   5730       unreachable("unknown bit width");
   5731    }
   5732 
   5733    return _dst_val;
   5734 }
   5735 static nir_const_value
   5736 evaluate_i2b(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5737                  MAYBE_UNUSED nir_const_value *_src)
   5738 {
   5739    nir_const_value _dst_val = { {0, } };
   5740 
   5741    switch (bit_size) {
   5742    case 32: {
   5743 
   5744 
   5745 
   5746          for (unsigned _i = 0; _i < num_components; _i++) {
   5747                   const int32_t src0 =
   5748                      _src[0].i32[_i];
   5749 
   5750                bool32_t dst = src0 != 0;
   5751 
   5752                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   5753          }
   5754 
   5755       break;
   5756    }
   5757    case 64: {
   5758 
   5759 
   5760 
   5761          for (unsigned _i = 0; _i < num_components; _i++) {
   5762                   const int32_t src0 =
   5763                      _src[0].i32[_i];
   5764 
   5765                bool32_t dst = src0 != 0;
   5766 
   5767                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   5768          }
   5769 
   5770       break;
   5771    }
   5772 
   5773    default:
   5774       unreachable("unknown bit width");
   5775    }
   5776 
   5777    return _dst_val;
   5778 }
   5779 static nir_const_value
   5780 evaluate_i2d(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5781                  MAYBE_UNUSED nir_const_value *_src)
   5782 {
   5783    nir_const_value _dst_val = { {0, } };
   5784 
   5785    switch (bit_size) {
   5786    case 32: {
   5787 
   5788 
   5789 
   5790          for (unsigned _i = 0; _i < num_components; _i++) {
   5791                   const int32_t src0 =
   5792                      _src[0].i32[_i];
   5793 
   5794                float64_t dst = src0;
   5795 
   5796                _dst_val.f64[_i] = dst;
   5797          }
   5798 
   5799       break;
   5800    }
   5801    case 64: {
   5802 
   5803 
   5804 
   5805          for (unsigned _i = 0; _i < num_components; _i++) {
   5806                   const int32_t src0 =
   5807                      _src[0].i32[_i];
   5808 
   5809                float64_t dst = src0;
   5810 
   5811                _dst_val.f64[_i] = dst;
   5812          }
   5813 
   5814       break;
   5815    }
   5816 
   5817    default:
   5818       unreachable("unknown bit width");
   5819    }
   5820 
   5821    return _dst_val;
   5822 }
   5823 static nir_const_value
   5824 evaluate_i2f(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5825                  MAYBE_UNUSED nir_const_value *_src)
   5826 {
   5827    nir_const_value _dst_val = { {0, } };
   5828 
   5829    switch (bit_size) {
   5830    case 32: {
   5831 
   5832 
   5833 
   5834          for (unsigned _i = 0; _i < num_components; _i++) {
   5835                   const int32_t src0 =
   5836                      _src[0].i32[_i];
   5837 
   5838                float32_t dst = src0;
   5839 
   5840                _dst_val.f32[_i] = dst;
   5841          }
   5842 
   5843       break;
   5844    }
   5845    case 64: {
   5846 
   5847 
   5848 
   5849          for (unsigned _i = 0; _i < num_components; _i++) {
   5850                   const int32_t src0 =
   5851                      _src[0].i32[_i];
   5852 
   5853                float32_t dst = src0;
   5854 
   5855                _dst_val.f32[_i] = dst;
   5856          }
   5857 
   5858       break;
   5859    }
   5860 
   5861    default:
   5862       unreachable("unknown bit width");
   5863    }
   5864 
   5865    return _dst_val;
   5866 }
   5867 static nir_const_value
   5868 evaluate_iabs(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5869                  MAYBE_UNUSED nir_const_value *_src)
   5870 {
   5871    nir_const_value _dst_val = { {0, } };
   5872 
   5873    switch (bit_size) {
   5874    case 32: {
   5875 
   5876 
   5877 
   5878          for (unsigned _i = 0; _i < num_components; _i++) {
   5879                   const int32_t src0 =
   5880                      _src[0].i32[_i];
   5881 
   5882                int32_t dst = (src0 < 0) ? -src0 : src0;
   5883 
   5884                _dst_val.i32[_i] = dst;
   5885          }
   5886 
   5887       break;
   5888    }
   5889    case 64: {
   5890 
   5891 
   5892 
   5893          for (unsigned _i = 0; _i < num_components; _i++) {
   5894                   const int64_t src0 =
   5895                      _src[0].i64[_i];
   5896 
   5897                int64_t dst = (src0 < 0) ? -src0 : src0;
   5898 
   5899                _dst_val.i64[_i] = dst;
   5900          }
   5901 
   5902       break;
   5903    }
   5904 
   5905    default:
   5906       unreachable("unknown bit width");
   5907    }
   5908 
   5909    return _dst_val;
   5910 }
   5911 static nir_const_value
   5912 evaluate_iadd(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5913                  MAYBE_UNUSED nir_const_value *_src)
   5914 {
   5915    nir_const_value _dst_val = { {0, } };
   5916 
   5917    switch (bit_size) {
   5918    case 32: {
   5919 
   5920 
   5921 
   5922          for (unsigned _i = 0; _i < num_components; _i++) {
   5923                   const int32_t src0 =
   5924                      _src[0].i32[_i];
   5925                   const int32_t src1 =
   5926                      _src[1].i32[_i];
   5927 
   5928                int32_t dst = src0 + src1;
   5929 
   5930                _dst_val.i32[_i] = dst;
   5931          }
   5932 
   5933       break;
   5934    }
   5935    case 64: {
   5936 
   5937 
   5938 
   5939          for (unsigned _i = 0; _i < num_components; _i++) {
   5940                   const int64_t src0 =
   5941                      _src[0].i64[_i];
   5942                   const int64_t src1 =
   5943                      _src[1].i64[_i];
   5944 
   5945                int64_t dst = src0 + src1;
   5946 
   5947                _dst_val.i64[_i] = dst;
   5948          }
   5949 
   5950       break;
   5951    }
   5952 
   5953    default:
   5954       unreachable("unknown bit width");
   5955    }
   5956 
   5957    return _dst_val;
   5958 }
   5959 static nir_const_value
   5960 evaluate_iand(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   5961                  MAYBE_UNUSED nir_const_value *_src)
   5962 {
   5963    nir_const_value _dst_val = { {0, } };
   5964 
   5965    switch (bit_size) {
   5966    case 32: {
   5967 
   5968 
   5969 
   5970          for (unsigned _i = 0; _i < num_components; _i++) {
   5971                   const uint32_t src0 =
   5972                      _src[0].u32[_i];
   5973                   const uint32_t src1 =
   5974                      _src[1].u32[_i];
   5975 
   5976                uint32_t dst = src0 & src1;
   5977 
   5978                _dst_val.u32[_i] = dst;
   5979          }
   5980 
   5981       break;
   5982    }
   5983    case 64: {
   5984 
   5985 
   5986 
   5987          for (unsigned _i = 0; _i < num_components; _i++) {
   5988                   const uint64_t src0 =
   5989                      _src[0].u64[_i];
   5990                   const uint64_t src1 =
   5991                      _src[1].u64[_i];
   5992 
   5993                uint64_t dst = src0 & src1;
   5994 
   5995                _dst_val.u64[_i] = dst;
   5996          }
   5997 
   5998       break;
   5999    }
   6000 
   6001    default:
   6002       unreachable("unknown bit width");
   6003    }
   6004 
   6005    return _dst_val;
   6006 }
   6007 static nir_const_value
   6008 evaluate_ibfe(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6009                  MAYBE_UNUSED nir_const_value *_src)
   6010 {
   6011    nir_const_value _dst_val = { {0, } };
   6012 
   6013    switch (bit_size) {
   6014    case 32: {
   6015 
   6016 
   6017 
   6018          for (unsigned _i = 0; _i < num_components; _i++) {
   6019                   const int32_t src0 =
   6020                      _src[0].i32[_i];
   6021                   const int32_t src1 =
   6022                      _src[1].i32[_i];
   6023                   const int32_t src2 =
   6024                      _src[2].i32[_i];
   6025 
   6026                int32_t dst;
   6027 
   6028 
   6029 int base = src0;
   6030 int offset = src1, bits = src2;
   6031 if (bits == 0) {
   6032    dst = 0;
   6033 } else if (bits < 0 || offset < 0) {
   6034    dst = 0; /* undefined */
   6035 } else if (offset + bits < 32) {
   6036    dst = (base << (32 - bits - offset)) >> (32 - bits);
   6037 } else {
   6038    dst = base >> offset;
   6039 }
   6040 
   6041 
   6042                _dst_val.i32[_i] = dst;
   6043          }
   6044 
   6045       break;
   6046    }
   6047    case 64: {
   6048 
   6049 
   6050 
   6051          for (unsigned _i = 0; _i < num_components; _i++) {
   6052                   const int32_t src0 =
   6053                      _src[0].i32[_i];
   6054                   const int32_t src1 =
   6055                      _src[1].i32[_i];
   6056                   const int32_t src2 =
   6057                      _src[2].i32[_i];
   6058 
   6059                int32_t dst;
   6060 
   6061 
   6062 int base = src0;
   6063 int offset = src1, bits = src2;
   6064 if (bits == 0) {
   6065    dst = 0;
   6066 } else if (bits < 0 || offset < 0) {
   6067    dst = 0; /* undefined */
   6068 } else if (offset + bits < 32) {
   6069    dst = (base << (32 - bits - offset)) >> (32 - bits);
   6070 } else {
   6071    dst = base >> offset;
   6072 }
   6073 
   6074 
   6075                _dst_val.i32[_i] = dst;
   6076          }
   6077 
   6078       break;
   6079    }
   6080 
   6081    default:
   6082       unreachable("unknown bit width");
   6083    }
   6084 
   6085    return _dst_val;
   6086 }
   6087 static nir_const_value
   6088 evaluate_ibitfield_extract(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6089                  MAYBE_UNUSED nir_const_value *_src)
   6090 {
   6091    nir_const_value _dst_val = { {0, } };
   6092 
   6093    switch (bit_size) {
   6094    case 32: {
   6095 
   6096 
   6097 
   6098          for (unsigned _i = 0; _i < num_components; _i++) {
   6099                   const int32_t src0 =
   6100                      _src[0].i32[_i];
   6101                   const int32_t src1 =
   6102                      _src[1].i32[_i];
   6103                   const int32_t src2 =
   6104                      _src[2].i32[_i];
   6105 
   6106                int32_t dst;
   6107 
   6108 
   6109 int base = src0;
   6110 int offset = src1, bits = src2;
   6111 if (bits == 0) {
   6112    dst = 0;
   6113 } else if (offset < 0 || bits < 0 || offset + bits > 32) {
   6114    dst = 0;
   6115 } else {
   6116    dst = (base << (32 - offset - bits)) >> offset; /* use sign-extending shift */
   6117 }
   6118 
   6119 
   6120                _dst_val.i32[_i] = dst;
   6121          }
   6122 
   6123       break;
   6124    }
   6125    case 64: {
   6126 
   6127 
   6128 
   6129          for (unsigned _i = 0; _i < num_components; _i++) {
   6130                   const int32_t src0 =
   6131                      _src[0].i32[_i];
   6132                   const int32_t src1 =
   6133                      _src[1].i32[_i];
   6134                   const int32_t src2 =
   6135                      _src[2].i32[_i];
   6136 
   6137                int32_t dst;
   6138 
   6139 
   6140 int base = src0;
   6141 int offset = src1, bits = src2;
   6142 if (bits == 0) {
   6143    dst = 0;
   6144 } else if (offset < 0 || bits < 0 || offset + bits > 32) {
   6145    dst = 0;
   6146 } else {
   6147    dst = (base << (32 - offset - bits)) >> offset; /* use sign-extending shift */
   6148 }
   6149 
   6150 
   6151                _dst_val.i32[_i] = dst;
   6152          }
   6153 
   6154       break;
   6155    }
   6156 
   6157    default:
   6158       unreachable("unknown bit width");
   6159    }
   6160 
   6161    return _dst_val;
   6162 }
   6163 static nir_const_value
   6164 evaluate_idiv(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6165                  MAYBE_UNUSED nir_const_value *_src)
   6166 {
   6167    nir_const_value _dst_val = { {0, } };
   6168 
   6169    switch (bit_size) {
   6170    case 32: {
   6171 
   6172 
   6173 
   6174          for (unsigned _i = 0; _i < num_components; _i++) {
   6175                   const int32_t src0 =
   6176                      _src[0].i32[_i];
   6177                   const int32_t src1 =
   6178                      _src[1].i32[_i];
   6179 
   6180                int32_t dst = src0 / src1;
   6181 
   6182                _dst_val.i32[_i] = dst;
   6183          }
   6184 
   6185       break;
   6186    }
   6187    case 64: {
   6188 
   6189 
   6190 
   6191          for (unsigned _i = 0; _i < num_components; _i++) {
   6192                   const int64_t src0 =
   6193                      _src[0].i64[_i];
   6194                   const int64_t src1 =
   6195                      _src[1].i64[_i];
   6196 
   6197                int64_t dst = src0 / src1;
   6198 
   6199                _dst_val.i64[_i] = dst;
   6200          }
   6201 
   6202       break;
   6203    }
   6204 
   6205    default:
   6206       unreachable("unknown bit width");
   6207    }
   6208 
   6209    return _dst_val;
   6210 }
   6211 static nir_const_value
   6212 evaluate_ieq(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6213                  MAYBE_UNUSED nir_const_value *_src)
   6214 {
   6215    nir_const_value _dst_val = { {0, } };
   6216 
   6217    switch (bit_size) {
   6218    case 32: {
   6219 
   6220 
   6221 
   6222          for (unsigned _i = 0; _i < num_components; _i++) {
   6223                   const int32_t src0 =
   6224                      _src[0].i32[_i];
   6225                   const int32_t src1 =
   6226                      _src[1].i32[_i];
   6227 
   6228                bool32_t dst = src0 == src1;
   6229 
   6230                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   6231          }
   6232 
   6233       break;
   6234    }
   6235    case 64: {
   6236 
   6237 
   6238 
   6239          for (unsigned _i = 0; _i < num_components; _i++) {
   6240                   const int64_t src0 =
   6241                      _src[0].i64[_i];
   6242                   const int64_t src1 =
   6243                      _src[1].i64[_i];
   6244 
   6245                bool32_t dst = src0 == src1;
   6246 
   6247                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   6248          }
   6249 
   6250       break;
   6251    }
   6252 
   6253    default:
   6254       unreachable("unknown bit width");
   6255    }
   6256 
   6257    return _dst_val;
   6258 }
   6259 static nir_const_value
   6260 evaluate_ifind_msb(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6261                  MAYBE_UNUSED nir_const_value *_src)
   6262 {
   6263    nir_const_value _dst_val = { {0, } };
   6264 
   6265    switch (bit_size) {
   6266    case 32: {
   6267 
   6268 
   6269 
   6270          for (unsigned _i = 0; _i < num_components; _i++) {
   6271                   const int32_t src0 =
   6272                      _src[0].i32[_i];
   6273 
   6274                int32_t dst;
   6275 
   6276 
   6277 dst = -1;
   6278 for (int bit = 31; bit >= 0; bit--) {
   6279    /* If src0 < 0, we're looking for the first 0 bit.
   6280     * if src0 >= 0, we're looking for the first 1 bit.
   6281     */
   6282    if ((((src0 >> bit) & 1) && (src0 >= 0)) ||
   6283       (!((src0 >> bit) & 1) && (src0 < 0))) {
   6284       dst = bit;
   6285       break;
   6286    }
   6287 }
   6288 
   6289 
   6290                _dst_val.i32[_i] = dst;
   6291          }
   6292 
   6293       break;
   6294    }
   6295    case 64: {
   6296 
   6297 
   6298 
   6299          for (unsigned _i = 0; _i < num_components; _i++) {
   6300                   const int32_t src0 =
   6301                      _src[0].i32[_i];
   6302 
   6303                int32_t dst;
   6304 
   6305 
   6306 dst = -1;
   6307 for (int bit = 31; bit >= 0; bit--) {
   6308    /* If src0 < 0, we're looking for the first 0 bit.
   6309     * if src0 >= 0, we're looking for the first 1 bit.
   6310     */
   6311    if ((((src0 >> bit) & 1) && (src0 >= 0)) ||
   6312       (!((src0 >> bit) & 1) && (src0 < 0))) {
   6313       dst = bit;
   6314       break;
   6315    }
   6316 }
   6317 
   6318 
   6319                _dst_val.i32[_i] = dst;
   6320          }
   6321 
   6322       break;
   6323    }
   6324 
   6325    default:
   6326       unreachable("unknown bit width");
   6327    }
   6328 
   6329    return _dst_val;
   6330 }
   6331 static nir_const_value
   6332 evaluate_ige(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6333                  MAYBE_UNUSED nir_const_value *_src)
   6334 {
   6335    nir_const_value _dst_val = { {0, } };
   6336 
   6337    switch (bit_size) {
   6338    case 32: {
   6339 
   6340 
   6341 
   6342          for (unsigned _i = 0; _i < num_components; _i++) {
   6343                   const int32_t src0 =
   6344                      _src[0].i32[_i];
   6345                   const int32_t src1 =
   6346                      _src[1].i32[_i];
   6347 
   6348                bool32_t dst = src0 >= src1;
   6349 
   6350                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   6351          }
   6352 
   6353       break;
   6354    }
   6355    case 64: {
   6356 
   6357 
   6358 
   6359          for (unsigned _i = 0; _i < num_components; _i++) {
   6360                   const int64_t src0 =
   6361                      _src[0].i64[_i];
   6362                   const int64_t src1 =
   6363                      _src[1].i64[_i];
   6364 
   6365                bool32_t dst = src0 >= src1;
   6366 
   6367                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   6368          }
   6369 
   6370       break;
   6371    }
   6372 
   6373    default:
   6374       unreachable("unknown bit width");
   6375    }
   6376 
   6377    return _dst_val;
   6378 }
   6379 static nir_const_value
   6380 evaluate_ilt(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6381                  MAYBE_UNUSED nir_const_value *_src)
   6382 {
   6383    nir_const_value _dst_val = { {0, } };
   6384 
   6385    switch (bit_size) {
   6386    case 32: {
   6387 
   6388 
   6389 
   6390          for (unsigned _i = 0; _i < num_components; _i++) {
   6391                   const int32_t src0 =
   6392                      _src[0].i32[_i];
   6393                   const int32_t src1 =
   6394                      _src[1].i32[_i];
   6395 
   6396                bool32_t dst = src0 < src1;
   6397 
   6398                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   6399          }
   6400 
   6401       break;
   6402    }
   6403    case 64: {
   6404 
   6405 
   6406 
   6407          for (unsigned _i = 0; _i < num_components; _i++) {
   6408                   const int64_t src0 =
   6409                      _src[0].i64[_i];
   6410                   const int64_t src1 =
   6411                      _src[1].i64[_i];
   6412 
   6413                bool32_t dst = src0 < src1;
   6414 
   6415                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   6416          }
   6417 
   6418       break;
   6419    }
   6420 
   6421    default:
   6422       unreachable("unknown bit width");
   6423    }
   6424 
   6425    return _dst_val;
   6426 }
   6427 static nir_const_value
   6428 evaluate_imax(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6429                  MAYBE_UNUSED nir_const_value *_src)
   6430 {
   6431    nir_const_value _dst_val = { {0, } };
   6432 
   6433    switch (bit_size) {
   6434    case 32: {
   6435 
   6436 
   6437 
   6438          for (unsigned _i = 0; _i < num_components; _i++) {
   6439                   const int32_t src0 =
   6440                      _src[0].i32[_i];
   6441                   const int32_t src1 =
   6442                      _src[1].i32[_i];
   6443 
   6444                int32_t dst = src1 > src0 ? src1 : src0;
   6445 
   6446                _dst_val.i32[_i] = dst;
   6447          }
   6448 
   6449       break;
   6450    }
   6451    case 64: {
   6452 
   6453 
   6454 
   6455          for (unsigned _i = 0; _i < num_components; _i++) {
   6456                   const int64_t src0 =
   6457                      _src[0].i64[_i];
   6458                   const int64_t src1 =
   6459                      _src[1].i64[_i];
   6460 
   6461                int64_t dst = src1 > src0 ? src1 : src0;
   6462 
   6463                _dst_val.i64[_i] = dst;
   6464          }
   6465 
   6466       break;
   6467    }
   6468 
   6469    default:
   6470       unreachable("unknown bit width");
   6471    }
   6472 
   6473    return _dst_val;
   6474 }
   6475 static nir_const_value
   6476 evaluate_imin(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6477                  MAYBE_UNUSED nir_const_value *_src)
   6478 {
   6479    nir_const_value _dst_val = { {0, } };
   6480 
   6481    switch (bit_size) {
   6482    case 32: {
   6483 
   6484 
   6485 
   6486          for (unsigned _i = 0; _i < num_components; _i++) {
   6487                   const int32_t src0 =
   6488                      _src[0].i32[_i];
   6489                   const int32_t src1 =
   6490                      _src[1].i32[_i];
   6491 
   6492                int32_t dst = src1 > src0 ? src0 : src1;
   6493 
   6494                _dst_val.i32[_i] = dst;
   6495          }
   6496 
   6497       break;
   6498    }
   6499    case 64: {
   6500 
   6501 
   6502 
   6503          for (unsigned _i = 0; _i < num_components; _i++) {
   6504                   const int64_t src0 =
   6505                      _src[0].i64[_i];
   6506                   const int64_t src1 =
   6507                      _src[1].i64[_i];
   6508 
   6509                int64_t dst = src1 > src0 ? src0 : src1;
   6510 
   6511                _dst_val.i64[_i] = dst;
   6512          }
   6513 
   6514       break;
   6515    }
   6516 
   6517    default:
   6518       unreachable("unknown bit width");
   6519    }
   6520 
   6521    return _dst_val;
   6522 }
   6523 static nir_const_value
   6524 evaluate_imod(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6525                  MAYBE_UNUSED nir_const_value *_src)
   6526 {
   6527    nir_const_value _dst_val = { {0, } };
   6528 
   6529    switch (bit_size) {
   6530    case 32: {
   6531 
   6532 
   6533 
   6534          for (unsigned _i = 0; _i < num_components; _i++) {
   6535                   const int32_t src0 =
   6536                      _src[0].i32[_i];
   6537                   const int32_t src1 =
   6538                      _src[1].i32[_i];
   6539 
   6540                int32_t dst = src1 == 0 ? 0 : ((src0 % src1 == 0 || (src0 >= 0) == (src1 >= 0)) ?                 src0 % src1 : src0 % src1 + src1);
   6541 
   6542                _dst_val.i32[_i] = dst;
   6543          }
   6544 
   6545       break;
   6546    }
   6547    case 64: {
   6548 
   6549 
   6550 
   6551          for (unsigned _i = 0; _i < num_components; _i++) {
   6552                   const int64_t src0 =
   6553                      _src[0].i64[_i];
   6554                   const int64_t src1 =
   6555                      _src[1].i64[_i];
   6556 
   6557                int64_t dst = src1 == 0 ? 0 : ((src0 % src1 == 0 || (src0 >= 0) == (src1 >= 0)) ?                 src0 % src1 : src0 % src1 + src1);
   6558 
   6559                _dst_val.i64[_i] = dst;
   6560          }
   6561 
   6562       break;
   6563    }
   6564 
   6565    default:
   6566       unreachable("unknown bit width");
   6567    }
   6568 
   6569    return _dst_val;
   6570 }
   6571 static nir_const_value
   6572 evaluate_imov(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6573                  MAYBE_UNUSED nir_const_value *_src)
   6574 {
   6575    nir_const_value _dst_val = { {0, } };
   6576 
   6577    switch (bit_size) {
   6578    case 32: {
   6579 
   6580 
   6581 
   6582          for (unsigned _i = 0; _i < num_components; _i++) {
   6583                   const int32_t src0 =
   6584                      _src[0].i32[_i];
   6585 
   6586                int32_t dst = src0;
   6587 
   6588                _dst_val.i32[_i] = dst;
   6589          }
   6590 
   6591       break;
   6592    }
   6593    case 64: {
   6594 
   6595 
   6596 
   6597          for (unsigned _i = 0; _i < num_components; _i++) {
   6598                   const int64_t src0 =
   6599                      _src[0].i64[_i];
   6600 
   6601                int64_t dst = src0;
   6602 
   6603                _dst_val.i64[_i] = dst;
   6604          }
   6605 
   6606       break;
   6607    }
   6608 
   6609    default:
   6610       unreachable("unknown bit width");
   6611    }
   6612 
   6613    return _dst_val;
   6614 }
   6615 static nir_const_value
   6616 evaluate_imul(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6617                  MAYBE_UNUSED nir_const_value *_src)
   6618 {
   6619    nir_const_value _dst_val = { {0, } };
   6620 
   6621    switch (bit_size) {
   6622    case 32: {
   6623 
   6624 
   6625 
   6626          for (unsigned _i = 0; _i < num_components; _i++) {
   6627                   const int32_t src0 =
   6628                      _src[0].i32[_i];
   6629                   const int32_t src1 =
   6630                      _src[1].i32[_i];
   6631 
   6632                int32_t dst = src0 * src1;
   6633 
   6634                _dst_val.i32[_i] = dst;
   6635          }
   6636 
   6637       break;
   6638    }
   6639    case 64: {
   6640 
   6641 
   6642 
   6643          for (unsigned _i = 0; _i < num_components; _i++) {
   6644                   const int64_t src0 =
   6645                      _src[0].i64[_i];
   6646                   const int64_t src1 =
   6647                      _src[1].i64[_i];
   6648 
   6649                int64_t dst = src0 * src1;
   6650 
   6651                _dst_val.i64[_i] = dst;
   6652          }
   6653 
   6654       break;
   6655    }
   6656 
   6657    default:
   6658       unreachable("unknown bit width");
   6659    }
   6660 
   6661    return _dst_val;
   6662 }
   6663 static nir_const_value
   6664 evaluate_imul_high(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6665                  MAYBE_UNUSED nir_const_value *_src)
   6666 {
   6667    nir_const_value _dst_val = { {0, } };
   6668 
   6669    switch (bit_size) {
   6670    case 32: {
   6671 
   6672 
   6673 
   6674          for (unsigned _i = 0; _i < num_components; _i++) {
   6675                   const int32_t src0 =
   6676                      _src[0].i32[_i];
   6677                   const int32_t src1 =
   6678                      _src[1].i32[_i];
   6679 
   6680                int32_t dst = (int32_t)(((int64_t) src0 * (int64_t) src1) >> 32);
   6681 
   6682                _dst_val.i32[_i] = dst;
   6683          }
   6684 
   6685       break;
   6686    }
   6687    case 64: {
   6688 
   6689 
   6690 
   6691          for (unsigned _i = 0; _i < num_components; _i++) {
   6692                   const int32_t src0 =
   6693                      _src[0].i32[_i];
   6694                   const int32_t src1 =
   6695                      _src[1].i32[_i];
   6696 
   6697                int32_t dst = (int32_t)(((int64_t) src0 * (int64_t) src1) >> 32);
   6698 
   6699                _dst_val.i32[_i] = dst;
   6700          }
   6701 
   6702       break;
   6703    }
   6704 
   6705    default:
   6706       unreachable("unknown bit width");
   6707    }
   6708 
   6709    return _dst_val;
   6710 }
   6711 static nir_const_value
   6712 evaluate_ine(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6713                  MAYBE_UNUSED nir_const_value *_src)
   6714 {
   6715    nir_const_value _dst_val = { {0, } };
   6716 
   6717    switch (bit_size) {
   6718    case 32: {
   6719 
   6720 
   6721 
   6722          for (unsigned _i = 0; _i < num_components; _i++) {
   6723                   const int32_t src0 =
   6724                      _src[0].i32[_i];
   6725                   const int32_t src1 =
   6726                      _src[1].i32[_i];
   6727 
   6728                bool32_t dst = src0 != src1;
   6729 
   6730                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   6731          }
   6732 
   6733       break;
   6734    }
   6735    case 64: {
   6736 
   6737 
   6738 
   6739          for (unsigned _i = 0; _i < num_components; _i++) {
   6740                   const int64_t src0 =
   6741                      _src[0].i64[_i];
   6742                   const int64_t src1 =
   6743                      _src[1].i64[_i];
   6744 
   6745                bool32_t dst = src0 != src1;
   6746 
   6747                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   6748          }
   6749 
   6750       break;
   6751    }
   6752 
   6753    default:
   6754       unreachable("unknown bit width");
   6755    }
   6756 
   6757    return _dst_val;
   6758 }
   6759 static nir_const_value
   6760 evaluate_ineg(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6761                  MAYBE_UNUSED nir_const_value *_src)
   6762 {
   6763    nir_const_value _dst_val = { {0, } };
   6764 
   6765    switch (bit_size) {
   6766    case 32: {
   6767 
   6768 
   6769 
   6770          for (unsigned _i = 0; _i < num_components; _i++) {
   6771                   const int32_t src0 =
   6772                      _src[0].i32[_i];
   6773 
   6774                int32_t dst = -src0;
   6775 
   6776                _dst_val.i32[_i] = dst;
   6777          }
   6778 
   6779       break;
   6780    }
   6781    case 64: {
   6782 
   6783 
   6784 
   6785          for (unsigned _i = 0; _i < num_components; _i++) {
   6786                   const int64_t src0 =
   6787                      _src[0].i64[_i];
   6788 
   6789                int64_t dst = -src0;
   6790 
   6791                _dst_val.i64[_i] = dst;
   6792          }
   6793 
   6794       break;
   6795    }
   6796 
   6797    default:
   6798       unreachable("unknown bit width");
   6799    }
   6800 
   6801    return _dst_val;
   6802 }
   6803 static nir_const_value
   6804 evaluate_inot(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6805                  MAYBE_UNUSED nir_const_value *_src)
   6806 {
   6807    nir_const_value _dst_val = { {0, } };
   6808 
   6809    switch (bit_size) {
   6810    case 32: {
   6811 
   6812 
   6813 
   6814          for (unsigned _i = 0; _i < num_components; _i++) {
   6815                   const int32_t src0 =
   6816                      _src[0].i32[_i];
   6817 
   6818                int32_t dst = ~src0;
   6819 
   6820                _dst_val.i32[_i] = dst;
   6821          }
   6822 
   6823       break;
   6824    }
   6825    case 64: {
   6826 
   6827 
   6828 
   6829          for (unsigned _i = 0; _i < num_components; _i++) {
   6830                   const int64_t src0 =
   6831                      _src[0].i64[_i];
   6832 
   6833                int64_t dst = ~src0;
   6834 
   6835                _dst_val.i64[_i] = dst;
   6836          }
   6837 
   6838       break;
   6839    }
   6840 
   6841    default:
   6842       unreachable("unknown bit width");
   6843    }
   6844 
   6845    return _dst_val;
   6846 }
   6847 static nir_const_value
   6848 evaluate_ior(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6849                  MAYBE_UNUSED nir_const_value *_src)
   6850 {
   6851    nir_const_value _dst_val = { {0, } };
   6852 
   6853    switch (bit_size) {
   6854    case 32: {
   6855 
   6856 
   6857 
   6858          for (unsigned _i = 0; _i < num_components; _i++) {
   6859                   const uint32_t src0 =
   6860                      _src[0].u32[_i];
   6861                   const uint32_t src1 =
   6862                      _src[1].u32[_i];
   6863 
   6864                uint32_t dst = src0 | src1;
   6865 
   6866                _dst_val.u32[_i] = dst;
   6867          }
   6868 
   6869       break;
   6870    }
   6871    case 64: {
   6872 
   6873 
   6874 
   6875          for (unsigned _i = 0; _i < num_components; _i++) {
   6876                   const uint64_t src0 =
   6877                      _src[0].u64[_i];
   6878                   const uint64_t src1 =
   6879                      _src[1].u64[_i];
   6880 
   6881                uint64_t dst = src0 | src1;
   6882 
   6883                _dst_val.u64[_i] = dst;
   6884          }
   6885 
   6886       break;
   6887    }
   6888 
   6889    default:
   6890       unreachable("unknown bit width");
   6891    }
   6892 
   6893    return _dst_val;
   6894 }
   6895 static nir_const_value
   6896 evaluate_irem(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6897                  MAYBE_UNUSED nir_const_value *_src)
   6898 {
   6899    nir_const_value _dst_val = { {0, } };
   6900 
   6901    switch (bit_size) {
   6902    case 32: {
   6903 
   6904 
   6905 
   6906          for (unsigned _i = 0; _i < num_components; _i++) {
   6907                   const int32_t src0 =
   6908                      _src[0].i32[_i];
   6909                   const int32_t src1 =
   6910                      _src[1].i32[_i];
   6911 
   6912                int32_t dst = src1 == 0 ? 0 : src0 % src1;
   6913 
   6914                _dst_val.i32[_i] = dst;
   6915          }
   6916 
   6917       break;
   6918    }
   6919    case 64: {
   6920 
   6921 
   6922 
   6923          for (unsigned _i = 0; _i < num_components; _i++) {
   6924                   const int64_t src0 =
   6925                      _src[0].i64[_i];
   6926                   const int64_t src1 =
   6927                      _src[1].i64[_i];
   6928 
   6929                int64_t dst = src1 == 0 ? 0 : src0 % src1;
   6930 
   6931                _dst_val.i64[_i] = dst;
   6932          }
   6933 
   6934       break;
   6935    }
   6936 
   6937    default:
   6938       unreachable("unknown bit width");
   6939    }
   6940 
   6941    return _dst_val;
   6942 }
   6943 static nir_const_value
   6944 evaluate_ishl(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6945                  MAYBE_UNUSED nir_const_value *_src)
   6946 {
   6947    nir_const_value _dst_val = { {0, } };
   6948 
   6949    switch (bit_size) {
   6950    case 32: {
   6951 
   6952 
   6953 
   6954          for (unsigned _i = 0; _i < num_components; _i++) {
   6955                   const int32_t src0 =
   6956                      _src[0].i32[_i];
   6957                   const int32_t src1 =
   6958                      _src[1].i32[_i];
   6959 
   6960                int32_t dst = src0 << src1;
   6961 
   6962                _dst_val.i32[_i] = dst;
   6963          }
   6964 
   6965       break;
   6966    }
   6967    case 64: {
   6968 
   6969 
   6970 
   6971          for (unsigned _i = 0; _i < num_components; _i++) {
   6972                   const int64_t src0 =
   6973                      _src[0].i64[_i];
   6974                   const int64_t src1 =
   6975                      _src[1].i64[_i];
   6976 
   6977                int64_t dst = src0 << src1;
   6978 
   6979                _dst_val.i64[_i] = dst;
   6980          }
   6981 
   6982       break;
   6983    }
   6984 
   6985    default:
   6986       unreachable("unknown bit width");
   6987    }
   6988 
   6989    return _dst_val;
   6990 }
   6991 static nir_const_value
   6992 evaluate_ishr(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   6993                  MAYBE_UNUSED nir_const_value *_src)
   6994 {
   6995    nir_const_value _dst_val = { {0, } };
   6996 
   6997    switch (bit_size) {
   6998    case 32: {
   6999 
   7000 
   7001 
   7002          for (unsigned _i = 0; _i < num_components; _i++) {
   7003                   const int32_t src0 =
   7004                      _src[0].i32[_i];
   7005                   const int32_t src1 =
   7006                      _src[1].i32[_i];
   7007 
   7008                int32_t dst = src0 >> src1;
   7009 
   7010                _dst_val.i32[_i] = dst;
   7011          }
   7012 
   7013       break;
   7014    }
   7015    case 64: {
   7016 
   7017 
   7018 
   7019          for (unsigned _i = 0; _i < num_components; _i++) {
   7020                   const int64_t src0 =
   7021                      _src[0].i64[_i];
   7022                   const int64_t src1 =
   7023                      _src[1].i64[_i];
   7024 
   7025                int64_t dst = src0 >> src1;
   7026 
   7027                _dst_val.i64[_i] = dst;
   7028          }
   7029 
   7030       break;
   7031    }
   7032 
   7033    default:
   7034       unreachable("unknown bit width");
   7035    }
   7036 
   7037    return _dst_val;
   7038 }
   7039 static nir_const_value
   7040 evaluate_isign(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7041                  MAYBE_UNUSED nir_const_value *_src)
   7042 {
   7043    nir_const_value _dst_val = { {0, } };
   7044 
   7045    switch (bit_size) {
   7046    case 32: {
   7047 
   7048 
   7049 
   7050          for (unsigned _i = 0; _i < num_components; _i++) {
   7051                   const int32_t src0 =
   7052                      _src[0].i32[_i];
   7053 
   7054                int32_t dst = (src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1);
   7055 
   7056                _dst_val.i32[_i] = dst;
   7057          }
   7058 
   7059       break;
   7060    }
   7061    case 64: {
   7062 
   7063 
   7064 
   7065          for (unsigned _i = 0; _i < num_components; _i++) {
   7066                   const int64_t src0 =
   7067                      _src[0].i64[_i];
   7068 
   7069                int64_t dst = (src0 == 0) ? 0 : ((src0 > 0) ? 1 : -1);
   7070 
   7071                _dst_val.i64[_i] = dst;
   7072          }
   7073 
   7074       break;
   7075    }
   7076 
   7077    default:
   7078       unreachable("unknown bit width");
   7079    }
   7080 
   7081    return _dst_val;
   7082 }
   7083 static nir_const_value
   7084 evaluate_isub(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7085                  MAYBE_UNUSED nir_const_value *_src)
   7086 {
   7087    nir_const_value _dst_val = { {0, } };
   7088 
   7089    switch (bit_size) {
   7090    case 32: {
   7091 
   7092 
   7093 
   7094          for (unsigned _i = 0; _i < num_components; _i++) {
   7095                   const int32_t src0 =
   7096                      _src[0].i32[_i];
   7097                   const int32_t src1 =
   7098                      _src[1].i32[_i];
   7099 
   7100                int32_t dst = src0 - src1;
   7101 
   7102                _dst_val.i32[_i] = dst;
   7103          }
   7104 
   7105       break;
   7106    }
   7107    case 64: {
   7108 
   7109 
   7110 
   7111          for (unsigned _i = 0; _i < num_components; _i++) {
   7112                   const int64_t src0 =
   7113                      _src[0].i64[_i];
   7114                   const int64_t src1 =
   7115                      _src[1].i64[_i];
   7116 
   7117                int64_t dst = src0 - src1;
   7118 
   7119                _dst_val.i64[_i] = dst;
   7120          }
   7121 
   7122       break;
   7123    }
   7124 
   7125    default:
   7126       unreachable("unknown bit width");
   7127    }
   7128 
   7129    return _dst_val;
   7130 }
   7131 static nir_const_value
   7132 evaluate_ixor(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7133                  MAYBE_UNUSED nir_const_value *_src)
   7134 {
   7135    nir_const_value _dst_val = { {0, } };
   7136 
   7137    switch (bit_size) {
   7138    case 32: {
   7139 
   7140 
   7141 
   7142          for (unsigned _i = 0; _i < num_components; _i++) {
   7143                   const uint32_t src0 =
   7144                      _src[0].u32[_i];
   7145                   const uint32_t src1 =
   7146                      _src[1].u32[_i];
   7147 
   7148                uint32_t dst = src0 ^ src1;
   7149 
   7150                _dst_val.u32[_i] = dst;
   7151          }
   7152 
   7153       break;
   7154    }
   7155    case 64: {
   7156 
   7157 
   7158 
   7159          for (unsigned _i = 0; _i < num_components; _i++) {
   7160                   const uint64_t src0 =
   7161                      _src[0].u64[_i];
   7162                   const uint64_t src1 =
   7163                      _src[1].u64[_i];
   7164 
   7165                uint64_t dst = src0 ^ src1;
   7166 
   7167                _dst_val.u64[_i] = dst;
   7168          }
   7169 
   7170       break;
   7171    }
   7172 
   7173    default:
   7174       unreachable("unknown bit width");
   7175    }
   7176 
   7177    return _dst_val;
   7178 }
   7179 static nir_const_value
   7180 evaluate_ldexp(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7181                  MAYBE_UNUSED nir_const_value *_src)
   7182 {
   7183    nir_const_value _dst_val = { {0, } };
   7184 
   7185    switch (bit_size) {
   7186    case 32: {
   7187 
   7188 
   7189 
   7190          for (unsigned _i = 0; _i < num_components; _i++) {
   7191                   const float32_t src0 =
   7192                      _src[0].f32[_i];
   7193                   const int32_t src1 =
   7194                      _src[1].i32[_i];
   7195 
   7196                float32_t dst;
   7197 
   7198 
   7199 dst = (bit_size == 64) ? ldexp(src0, src1) : ldexpf(src0, src1);
   7200 /* flush denormals to zero. */
   7201 if (!isnormal(dst))
   7202    dst = copysignf(0.0f, src0);
   7203 
   7204 
   7205                _dst_val.f32[_i] = dst;
   7206          }
   7207 
   7208       break;
   7209    }
   7210    case 64: {
   7211 
   7212 
   7213 
   7214          for (unsigned _i = 0; _i < num_components; _i++) {
   7215                   const float64_t src0 =
   7216                      _src[0].f64[_i];
   7217                   const int32_t src1 =
   7218                      _src[1].i32[_i];
   7219 
   7220                float64_t dst;
   7221 
   7222 
   7223 dst = (bit_size == 64) ? ldexp(src0, src1) : ldexpf(src0, src1);
   7224 /* flush denormals to zero. */
   7225 if (!isnormal(dst))
   7226    dst = copysignf(0.0f, src0);
   7227 
   7228 
   7229                _dst_val.f64[_i] = dst;
   7230          }
   7231 
   7232       break;
   7233    }
   7234 
   7235    default:
   7236       unreachable("unknown bit width");
   7237    }
   7238 
   7239    return _dst_val;
   7240 }
   7241 static nir_const_value
   7242 evaluate_pack_double_2x32(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7243                  MAYBE_UNUSED nir_const_value *_src)
   7244 {
   7245    nir_const_value _dst_val = { {0, } };
   7246 
   7247    switch (bit_size) {
   7248    case 32: {
   7249 
   7250 
   7251 
   7252          const struct uint32_vec src0 = {
   7253                _src[0].u32[0],
   7254                _src[0].u32[1],
   7255             0,
   7256             0,
   7257          };
   7258 
   7259          struct uint64_vec dst;
   7260 
   7261             dst.x = src0.x | ((uint64_t)src0.y << 32);
   7262 
   7263                _dst_val.u64[0] = dst.x;
   7264 
   7265       break;
   7266    }
   7267    case 64: {
   7268 
   7269 
   7270 
   7271          const struct uint32_vec src0 = {
   7272                _src[0].u32[0],
   7273                _src[0].u32[1],
   7274             0,
   7275             0,
   7276          };
   7277 
   7278          struct uint64_vec dst;
   7279 
   7280             dst.x = src0.x | ((uint64_t)src0.y << 32);
   7281 
   7282                _dst_val.u64[0] = dst.x;
   7283 
   7284       break;
   7285    }
   7286 
   7287    default:
   7288       unreachable("unknown bit width");
   7289    }
   7290 
   7291    return _dst_val;
   7292 }
   7293 static nir_const_value
   7294 evaluate_pack_double_2x32_split(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7295                  MAYBE_UNUSED nir_const_value *_src)
   7296 {
   7297    nir_const_value _dst_val = { {0, } };
   7298 
   7299    switch (bit_size) {
   7300    case 32: {
   7301 
   7302 
   7303 
   7304          for (unsigned _i = 0; _i < num_components; _i++) {
   7305                   const uint32_t src0 =
   7306                      _src[0].u32[_i];
   7307                   const uint32_t src1 =
   7308                      _src[1].u32[_i];
   7309 
   7310                uint64_t dst = src0 | ((uint64_t)src1 << 32);
   7311 
   7312                _dst_val.u64[_i] = dst;
   7313          }
   7314 
   7315       break;
   7316    }
   7317    case 64: {
   7318 
   7319 
   7320 
   7321          for (unsigned _i = 0; _i < num_components; _i++) {
   7322                   const uint32_t src0 =
   7323                      _src[0].u32[_i];
   7324                   const uint32_t src1 =
   7325                      _src[1].u32[_i];
   7326 
   7327                uint64_t dst = src0 | ((uint64_t)src1 << 32);
   7328 
   7329                _dst_val.u64[_i] = dst;
   7330          }
   7331 
   7332       break;
   7333    }
   7334 
   7335    default:
   7336       unreachable("unknown bit width");
   7337    }
   7338 
   7339    return _dst_val;
   7340 }
   7341 static nir_const_value
   7342 evaluate_pack_half_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7343                  MAYBE_UNUSED nir_const_value *_src)
   7344 {
   7345    nir_const_value _dst_val = { {0, } };
   7346 
   7347    switch (bit_size) {
   7348    case 32: {
   7349 
   7350 
   7351 
   7352          const struct float32_vec src0 = {
   7353                _src[0].f32[0],
   7354                _src[0].f32[1],
   7355             0,
   7356             0,
   7357          };
   7358 
   7359          struct uint32_vec dst;
   7360 
   7361 
   7362 dst.x = (uint32_t) pack_half_1x16(src0.x);
   7363 dst.x |= ((uint32_t) pack_half_1x16(src0.y)) << 16;
   7364 
   7365 
   7366                _dst_val.u32[0] = dst.x;
   7367 
   7368       break;
   7369    }
   7370    case 64: {
   7371 
   7372 
   7373 
   7374          const struct float32_vec src0 = {
   7375                _src[0].f32[0],
   7376                _src[0].f32[1],
   7377             0,
   7378             0,
   7379          };
   7380 
   7381          struct uint32_vec dst;
   7382 
   7383 
   7384 dst.x = (uint32_t) pack_half_1x16(src0.x);
   7385 dst.x |= ((uint32_t) pack_half_1x16(src0.y)) << 16;
   7386 
   7387 
   7388                _dst_val.u32[0] = dst.x;
   7389 
   7390       break;
   7391    }
   7392 
   7393    default:
   7394       unreachable("unknown bit width");
   7395    }
   7396 
   7397    return _dst_val;
   7398 }
   7399 static nir_const_value
   7400 evaluate_pack_half_2x16_split(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7401                  MAYBE_UNUSED nir_const_value *_src)
   7402 {
   7403    nir_const_value _dst_val = { {0, } };
   7404 
   7405    switch (bit_size) {
   7406    case 32: {
   7407 
   7408 
   7409 
   7410          const struct float32_vec src0 = {
   7411                _src[0].f32[0],
   7412             0,
   7413             0,
   7414             0,
   7415          };
   7416 
   7417          const struct float32_vec src1 = {
   7418                _src[1].f32[0],
   7419             0,
   7420             0,
   7421             0,
   7422          };
   7423 
   7424          struct uint32_vec dst;
   7425 
   7426             dst.x = dst.y = dst.z = dst.w = pack_half_1x16(src0.x) | (pack_half_1x16(src1.x) << 16);
   7427 
   7428                _dst_val.u32[0] = dst.x;
   7429 
   7430       break;
   7431    }
   7432    case 64: {
   7433 
   7434 
   7435 
   7436          const struct float32_vec src0 = {
   7437                _src[0].f32[0],
   7438             0,
   7439             0,
   7440             0,
   7441          };
   7442 
   7443          const struct float32_vec src1 = {
   7444                _src[1].f32[0],
   7445             0,
   7446             0,
   7447             0,
   7448          };
   7449 
   7450          struct uint32_vec dst;
   7451 
   7452             dst.x = dst.y = dst.z = dst.w = pack_half_1x16(src0.x) | (pack_half_1x16(src1.x) << 16);
   7453 
   7454                _dst_val.u32[0] = dst.x;
   7455 
   7456       break;
   7457    }
   7458 
   7459    default:
   7460       unreachable("unknown bit width");
   7461    }
   7462 
   7463    return _dst_val;
   7464 }
   7465 static nir_const_value
   7466 evaluate_pack_snorm_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7467                  MAYBE_UNUSED nir_const_value *_src)
   7468 {
   7469    nir_const_value _dst_val = { {0, } };
   7470 
   7471    switch (bit_size) {
   7472    case 32: {
   7473 
   7474 
   7475 
   7476          const struct float32_vec src0 = {
   7477                _src[0].f32[0],
   7478                _src[0].f32[1],
   7479             0,
   7480             0,
   7481          };
   7482 
   7483          struct uint32_vec dst;
   7484 
   7485 
   7486 dst.x = (uint32_t) pack_snorm_1x16(src0.x);
   7487 dst.x |= ((uint32_t) pack_snorm_1x16(src0.y)) << 16;
   7488 
   7489 
   7490                _dst_val.u32[0] = dst.x;
   7491 
   7492       break;
   7493    }
   7494    case 64: {
   7495 
   7496 
   7497 
   7498          const struct float32_vec src0 = {
   7499                _src[0].f32[0],
   7500                _src[0].f32[1],
   7501             0,
   7502             0,
   7503          };
   7504 
   7505          struct uint32_vec dst;
   7506 
   7507 
   7508 dst.x = (uint32_t) pack_snorm_1x16(src0.x);
   7509 dst.x |= ((uint32_t) pack_snorm_1x16(src0.y)) << 16;
   7510 
   7511 
   7512                _dst_val.u32[0] = dst.x;
   7513 
   7514       break;
   7515    }
   7516 
   7517    default:
   7518       unreachable("unknown bit width");
   7519    }
   7520 
   7521    return _dst_val;
   7522 }
   7523 static nir_const_value
   7524 evaluate_pack_snorm_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7525                  MAYBE_UNUSED nir_const_value *_src)
   7526 {
   7527    nir_const_value _dst_val = { {0, } };
   7528 
   7529    switch (bit_size) {
   7530    case 32: {
   7531 
   7532 
   7533 
   7534          const struct float32_vec src0 = {
   7535                _src[0].f32[0],
   7536                _src[0].f32[1],
   7537                _src[0].f32[2],
   7538                _src[0].f32[3],
   7539          };
   7540 
   7541          struct uint32_vec dst;
   7542 
   7543 
   7544 dst.x = (uint32_t) pack_snorm_1x8(src0.x);
   7545 dst.x |= ((uint32_t) pack_snorm_1x8(src0.y)) << 8;
   7546 dst.x |= ((uint32_t) pack_snorm_1x8(src0.z)) << 16;
   7547 dst.x |= ((uint32_t) pack_snorm_1x8(src0.w)) << 24;
   7548 
   7549 
   7550                _dst_val.u32[0] = dst.x;
   7551 
   7552       break;
   7553    }
   7554    case 64: {
   7555 
   7556 
   7557 
   7558          const struct float32_vec src0 = {
   7559                _src[0].f32[0],
   7560                _src[0].f32[1],
   7561                _src[0].f32[2],
   7562                _src[0].f32[3],
   7563          };
   7564 
   7565          struct uint32_vec dst;
   7566 
   7567 
   7568 dst.x = (uint32_t) pack_snorm_1x8(src0.x);
   7569 dst.x |= ((uint32_t) pack_snorm_1x8(src0.y)) << 8;
   7570 dst.x |= ((uint32_t) pack_snorm_1x8(src0.z)) << 16;
   7571 dst.x |= ((uint32_t) pack_snorm_1x8(src0.w)) << 24;
   7572 
   7573 
   7574                _dst_val.u32[0] = dst.x;
   7575 
   7576       break;
   7577    }
   7578 
   7579    default:
   7580       unreachable("unknown bit width");
   7581    }
   7582 
   7583    return _dst_val;
   7584 }
   7585 static nir_const_value
   7586 evaluate_pack_unorm_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7587                  MAYBE_UNUSED nir_const_value *_src)
   7588 {
   7589    nir_const_value _dst_val = { {0, } };
   7590 
   7591    switch (bit_size) {
   7592    case 32: {
   7593 
   7594 
   7595 
   7596          const struct float32_vec src0 = {
   7597                _src[0].f32[0],
   7598                _src[0].f32[1],
   7599             0,
   7600             0,
   7601          };
   7602 
   7603          struct uint32_vec dst;
   7604 
   7605 
   7606 dst.x = (uint32_t) pack_unorm_1x16(src0.x);
   7607 dst.x |= ((uint32_t) pack_unorm_1x16(src0.y)) << 16;
   7608 
   7609 
   7610                _dst_val.u32[0] = dst.x;
   7611 
   7612       break;
   7613    }
   7614    case 64: {
   7615 
   7616 
   7617 
   7618          const struct float32_vec src0 = {
   7619                _src[0].f32[0],
   7620                _src[0].f32[1],
   7621             0,
   7622             0,
   7623          };
   7624 
   7625          struct uint32_vec dst;
   7626 
   7627 
   7628 dst.x = (uint32_t) pack_unorm_1x16(src0.x);
   7629 dst.x |= ((uint32_t) pack_unorm_1x16(src0.y)) << 16;
   7630 
   7631 
   7632                _dst_val.u32[0] = dst.x;
   7633 
   7634       break;
   7635    }
   7636 
   7637    default:
   7638       unreachable("unknown bit width");
   7639    }
   7640 
   7641    return _dst_val;
   7642 }
   7643 static nir_const_value
   7644 evaluate_pack_unorm_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7645                  MAYBE_UNUSED nir_const_value *_src)
   7646 {
   7647    nir_const_value _dst_val = { {0, } };
   7648 
   7649    switch (bit_size) {
   7650    case 32: {
   7651 
   7652 
   7653 
   7654          const struct float32_vec src0 = {
   7655                _src[0].f32[0],
   7656                _src[0].f32[1],
   7657                _src[0].f32[2],
   7658                _src[0].f32[3],
   7659          };
   7660 
   7661          struct uint32_vec dst;
   7662 
   7663 
   7664 dst.x = (uint32_t) pack_unorm_1x8(src0.x);
   7665 dst.x |= ((uint32_t) pack_unorm_1x8(src0.y)) << 8;
   7666 dst.x |= ((uint32_t) pack_unorm_1x8(src0.z)) << 16;
   7667 dst.x |= ((uint32_t) pack_unorm_1x8(src0.w)) << 24;
   7668 
   7669 
   7670                _dst_val.u32[0] = dst.x;
   7671 
   7672       break;
   7673    }
   7674    case 64: {
   7675 
   7676 
   7677 
   7678          const struct float32_vec src0 = {
   7679                _src[0].f32[0],
   7680                _src[0].f32[1],
   7681                _src[0].f32[2],
   7682                _src[0].f32[3],
   7683          };
   7684 
   7685          struct uint32_vec dst;
   7686 
   7687 
   7688 dst.x = (uint32_t) pack_unorm_1x8(src0.x);
   7689 dst.x |= ((uint32_t) pack_unorm_1x8(src0.y)) << 8;
   7690 dst.x |= ((uint32_t) pack_unorm_1x8(src0.z)) << 16;
   7691 dst.x |= ((uint32_t) pack_unorm_1x8(src0.w)) << 24;
   7692 
   7693 
   7694                _dst_val.u32[0] = dst.x;
   7695 
   7696       break;
   7697    }
   7698 
   7699    default:
   7700       unreachable("unknown bit width");
   7701    }
   7702 
   7703    return _dst_val;
   7704 }
   7705 static nir_const_value
   7706 evaluate_pack_uvec2_to_uint(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7707                  MAYBE_UNUSED nir_const_value *_src)
   7708 {
   7709    nir_const_value _dst_val = { {0, } };
   7710 
   7711    switch (bit_size) {
   7712    case 32: {
   7713 
   7714 
   7715 
   7716          const struct uint32_vec src0 = {
   7717                _src[0].u32[0],
   7718                _src[0].u32[1],
   7719             0,
   7720             0,
   7721          };
   7722 
   7723          struct uint32_vec dst;
   7724 
   7725 
   7726 dst.x = (src0.x & 0xffff) | (src0.y << 16);
   7727 
   7728 
   7729                _dst_val.u32[0] = dst.x;
   7730 
   7731       break;
   7732    }
   7733    case 64: {
   7734 
   7735 
   7736 
   7737          const struct uint32_vec src0 = {
   7738                _src[0].u32[0],
   7739                _src[0].u32[1],
   7740             0,
   7741             0,
   7742          };
   7743 
   7744          struct uint32_vec dst;
   7745 
   7746 
   7747 dst.x = (src0.x & 0xffff) | (src0.y << 16);
   7748 
   7749 
   7750                _dst_val.u32[0] = dst.x;
   7751 
   7752       break;
   7753    }
   7754 
   7755    default:
   7756       unreachable("unknown bit width");
   7757    }
   7758 
   7759    return _dst_val;
   7760 }
   7761 static nir_const_value
   7762 evaluate_pack_uvec4_to_uint(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7763                  MAYBE_UNUSED nir_const_value *_src)
   7764 {
   7765    nir_const_value _dst_val = { {0, } };
   7766 
   7767    switch (bit_size) {
   7768    case 32: {
   7769 
   7770 
   7771 
   7772          const struct uint32_vec src0 = {
   7773                _src[0].u32[0],
   7774                _src[0].u32[1],
   7775                _src[0].u32[2],
   7776                _src[0].u32[3],
   7777          };
   7778 
   7779          struct uint32_vec dst;
   7780 
   7781 
   7782 dst.x = (src0.x <<  0) |
   7783         (src0.y <<  8) |
   7784         (src0.z << 16) |
   7785         (src0.w << 24);
   7786 
   7787 
   7788                _dst_val.u32[0] = dst.x;
   7789 
   7790       break;
   7791    }
   7792    case 64: {
   7793 
   7794 
   7795 
   7796          const struct uint32_vec src0 = {
   7797                _src[0].u32[0],
   7798                _src[0].u32[1],
   7799                _src[0].u32[2],
   7800                _src[0].u32[3],
   7801          };
   7802 
   7803          struct uint32_vec dst;
   7804 
   7805 
   7806 dst.x = (src0.x <<  0) |
   7807         (src0.y <<  8) |
   7808         (src0.z << 16) |
   7809         (src0.w << 24);
   7810 
   7811 
   7812                _dst_val.u32[0] = dst.x;
   7813 
   7814       break;
   7815    }
   7816 
   7817    default:
   7818       unreachable("unknown bit width");
   7819    }
   7820 
   7821    return _dst_val;
   7822 }
   7823 static nir_const_value
   7824 evaluate_seq(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7825                  MAYBE_UNUSED nir_const_value *_src)
   7826 {
   7827    nir_const_value _dst_val = { {0, } };
   7828 
   7829    switch (bit_size) {
   7830    case 32: {
   7831 
   7832 
   7833 
   7834          for (unsigned _i = 0; _i < num_components; _i++) {
   7835                   const float32_t src0 =
   7836                      _src[0].f32[_i];
   7837                   const float32_t src1 =
   7838                      _src[1].f32[_i];
   7839 
   7840                float32_t dst = (src0 == src1) ? 1.0f : 0.0f;
   7841 
   7842                _dst_val.f32[_i] = dst;
   7843          }
   7844 
   7845       break;
   7846    }
   7847    case 64: {
   7848 
   7849 
   7850 
   7851          for (unsigned _i = 0; _i < num_components; _i++) {
   7852                   const float32_t src0 =
   7853                      _src[0].f32[_i];
   7854                   const float32_t src1 =
   7855                      _src[1].f32[_i];
   7856 
   7857                float32_t dst = (src0 == src1) ? 1.0f : 0.0f;
   7858 
   7859                _dst_val.f32[_i] = dst;
   7860          }
   7861 
   7862       break;
   7863    }
   7864 
   7865    default:
   7866       unreachable("unknown bit width");
   7867    }
   7868 
   7869    return _dst_val;
   7870 }
   7871 static nir_const_value
   7872 evaluate_sge(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7873                  MAYBE_UNUSED nir_const_value *_src)
   7874 {
   7875    nir_const_value _dst_val = { {0, } };
   7876 
   7877    switch (bit_size) {
   7878    case 32: {
   7879 
   7880 
   7881 
   7882          for (unsigned _i = 0; _i < num_components; _i++) {
   7883                   const float32_t src0 =
   7884                      _src[0].f32[_i];
   7885                   const float32_t src1 =
   7886                      _src[1].f32[_i];
   7887 
   7888                float32_t dst = (src0 >= src1) ? 1.0f : 0.0f;
   7889 
   7890                _dst_val.f32[_i] = dst;
   7891          }
   7892 
   7893       break;
   7894    }
   7895    case 64: {
   7896 
   7897 
   7898 
   7899          for (unsigned _i = 0; _i < num_components; _i++) {
   7900                   const float32_t src0 =
   7901                      _src[0].f32[_i];
   7902                   const float32_t src1 =
   7903                      _src[1].f32[_i];
   7904 
   7905                float32_t dst = (src0 >= src1) ? 1.0f : 0.0f;
   7906 
   7907                _dst_val.f32[_i] = dst;
   7908          }
   7909 
   7910       break;
   7911    }
   7912 
   7913    default:
   7914       unreachable("unknown bit width");
   7915    }
   7916 
   7917    return _dst_val;
   7918 }
   7919 static nir_const_value
   7920 evaluate_slt(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7921                  MAYBE_UNUSED nir_const_value *_src)
   7922 {
   7923    nir_const_value _dst_val = { {0, } };
   7924 
   7925    switch (bit_size) {
   7926    case 32: {
   7927 
   7928 
   7929 
   7930          for (unsigned _i = 0; _i < num_components; _i++) {
   7931                   const float32_t src0 =
   7932                      _src[0].f32[_i];
   7933                   const float32_t src1 =
   7934                      _src[1].f32[_i];
   7935 
   7936                float32_t dst = (src0 < src1) ? 1.0f : 0.0f;
   7937 
   7938                _dst_val.f32[_i] = dst;
   7939          }
   7940 
   7941       break;
   7942    }
   7943    case 64: {
   7944 
   7945 
   7946 
   7947          for (unsigned _i = 0; _i < num_components; _i++) {
   7948                   const float32_t src0 =
   7949                      _src[0].f32[_i];
   7950                   const float32_t src1 =
   7951                      _src[1].f32[_i];
   7952 
   7953                float32_t dst = (src0 < src1) ? 1.0f : 0.0f;
   7954 
   7955                _dst_val.f32[_i] = dst;
   7956          }
   7957 
   7958       break;
   7959    }
   7960 
   7961    default:
   7962       unreachable("unknown bit width");
   7963    }
   7964 
   7965    return _dst_val;
   7966 }
   7967 static nir_const_value
   7968 evaluate_sne(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   7969                  MAYBE_UNUSED nir_const_value *_src)
   7970 {
   7971    nir_const_value _dst_val = { {0, } };
   7972 
   7973    switch (bit_size) {
   7974    case 32: {
   7975 
   7976 
   7977 
   7978          for (unsigned _i = 0; _i < num_components; _i++) {
   7979                   const float32_t src0 =
   7980                      _src[0].f32[_i];
   7981                   const float32_t src1 =
   7982                      _src[1].f32[_i];
   7983 
   7984                float32_t dst = (src0 != src1) ? 1.0f : 0.0f;
   7985 
   7986                _dst_val.f32[_i] = dst;
   7987          }
   7988 
   7989       break;
   7990    }
   7991    case 64: {
   7992 
   7993 
   7994 
   7995          for (unsigned _i = 0; _i < num_components; _i++) {
   7996                   const float32_t src0 =
   7997                      _src[0].f32[_i];
   7998                   const float32_t src1 =
   7999                      _src[1].f32[_i];
   8000 
   8001                float32_t dst = (src0 != src1) ? 1.0f : 0.0f;
   8002 
   8003                _dst_val.f32[_i] = dst;
   8004          }
   8005 
   8006       break;
   8007    }
   8008 
   8009    default:
   8010       unreachable("unknown bit width");
   8011    }
   8012 
   8013    return _dst_val;
   8014 }
   8015 static nir_const_value
   8016 evaluate_u2d(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8017                  MAYBE_UNUSED nir_const_value *_src)
   8018 {
   8019    nir_const_value _dst_val = { {0, } };
   8020 
   8021    switch (bit_size) {
   8022    case 32: {
   8023 
   8024 
   8025 
   8026          for (unsigned _i = 0; _i < num_components; _i++) {
   8027                   const uint32_t src0 =
   8028                      _src[0].u32[_i];
   8029 
   8030                float64_t dst = src0;
   8031 
   8032                _dst_val.f64[_i] = dst;
   8033          }
   8034 
   8035       break;
   8036    }
   8037    case 64: {
   8038 
   8039 
   8040 
   8041          for (unsigned _i = 0; _i < num_components; _i++) {
   8042                   const uint32_t src0 =
   8043                      _src[0].u32[_i];
   8044 
   8045                float64_t dst = src0;
   8046 
   8047                _dst_val.f64[_i] = dst;
   8048          }
   8049 
   8050       break;
   8051    }
   8052 
   8053    default:
   8054       unreachable("unknown bit width");
   8055    }
   8056 
   8057    return _dst_val;
   8058 }
   8059 static nir_const_value
   8060 evaluate_u2f(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8061                  MAYBE_UNUSED nir_const_value *_src)
   8062 {
   8063    nir_const_value _dst_val = { {0, } };
   8064 
   8065    switch (bit_size) {
   8066    case 32: {
   8067 
   8068 
   8069 
   8070          for (unsigned _i = 0; _i < num_components; _i++) {
   8071                   const uint32_t src0 =
   8072                      _src[0].u32[_i];
   8073 
   8074                float32_t dst = src0;
   8075 
   8076                _dst_val.f32[_i] = dst;
   8077          }
   8078 
   8079       break;
   8080    }
   8081    case 64: {
   8082 
   8083 
   8084 
   8085          for (unsigned _i = 0; _i < num_components; _i++) {
   8086                   const uint32_t src0 =
   8087                      _src[0].u32[_i];
   8088 
   8089                float32_t dst = src0;
   8090 
   8091                _dst_val.f32[_i] = dst;
   8092          }
   8093 
   8094       break;
   8095    }
   8096 
   8097    default:
   8098       unreachable("unknown bit width");
   8099    }
   8100 
   8101    return _dst_val;
   8102 }
   8103 static nir_const_value
   8104 evaluate_uadd_carry(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8105                  MAYBE_UNUSED nir_const_value *_src)
   8106 {
   8107    nir_const_value _dst_val = { {0, } };
   8108 
   8109    switch (bit_size) {
   8110    case 32: {
   8111 
   8112 
   8113 
   8114          for (unsigned _i = 0; _i < num_components; _i++) {
   8115                   const uint32_t src0 =
   8116                      _src[0].u32[_i];
   8117                   const uint32_t src1 =
   8118                      _src[1].u32[_i];
   8119 
   8120                uint32_t dst = src0 + src1 < src0;
   8121 
   8122                _dst_val.u32[_i] = dst;
   8123          }
   8124 
   8125       break;
   8126    }
   8127    case 64: {
   8128 
   8129 
   8130 
   8131          for (unsigned _i = 0; _i < num_components; _i++) {
   8132                   const uint64_t src0 =
   8133                      _src[0].u64[_i];
   8134                   const uint64_t src1 =
   8135                      _src[1].u64[_i];
   8136 
   8137                uint64_t dst = src0 + src1 < src0;
   8138 
   8139                _dst_val.u64[_i] = dst;
   8140          }
   8141 
   8142       break;
   8143    }
   8144 
   8145    default:
   8146       unreachable("unknown bit width");
   8147    }
   8148 
   8149    return _dst_val;
   8150 }
   8151 static nir_const_value
   8152 evaluate_ubfe(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8153                  MAYBE_UNUSED nir_const_value *_src)
   8154 {
   8155    nir_const_value _dst_val = { {0, } };
   8156 
   8157    switch (bit_size) {
   8158    case 32: {
   8159 
   8160 
   8161 
   8162          for (unsigned _i = 0; _i < num_components; _i++) {
   8163                   const uint32_t src0 =
   8164                      _src[0].u32[_i];
   8165                   const int32_t src1 =
   8166                      _src[1].i32[_i];
   8167                   const int32_t src2 =
   8168                      _src[2].i32[_i];
   8169 
   8170                uint32_t dst;
   8171 
   8172 
   8173 unsigned base = src0;
   8174 int offset = src1, bits = src2;
   8175 if (bits == 0) {
   8176    dst = 0;
   8177 } else if (bits < 0 || offset < 0) {
   8178    dst = 0; /* undefined */
   8179 } else if (offset + bits < 32) {
   8180    dst = (base << (32 - bits - offset)) >> (32 - bits);
   8181 } else {
   8182    dst = base >> offset;
   8183 }
   8184 
   8185 
   8186                _dst_val.u32[_i] = dst;
   8187          }
   8188 
   8189       break;
   8190    }
   8191    case 64: {
   8192 
   8193 
   8194 
   8195          for (unsigned _i = 0; _i < num_components; _i++) {
   8196                   const uint32_t src0 =
   8197                      _src[0].u32[_i];
   8198                   const int32_t src1 =
   8199                      _src[1].i32[_i];
   8200                   const int32_t src2 =
   8201                      _src[2].i32[_i];
   8202 
   8203                uint32_t dst;
   8204 
   8205 
   8206 unsigned base = src0;
   8207 int offset = src1, bits = src2;
   8208 if (bits == 0) {
   8209    dst = 0;
   8210 } else if (bits < 0 || offset < 0) {
   8211    dst = 0; /* undefined */
   8212 } else if (offset + bits < 32) {
   8213    dst = (base << (32 - bits - offset)) >> (32 - bits);
   8214 } else {
   8215    dst = base >> offset;
   8216 }
   8217 
   8218 
   8219                _dst_val.u32[_i] = dst;
   8220          }
   8221 
   8222       break;
   8223    }
   8224 
   8225    default:
   8226       unreachable("unknown bit width");
   8227    }
   8228 
   8229    return _dst_val;
   8230 }
   8231 static nir_const_value
   8232 evaluate_ubitfield_extract(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8233                  MAYBE_UNUSED nir_const_value *_src)
   8234 {
   8235    nir_const_value _dst_val = { {0, } };
   8236 
   8237    switch (bit_size) {
   8238    case 32: {
   8239 
   8240 
   8241 
   8242          for (unsigned _i = 0; _i < num_components; _i++) {
   8243                   const uint32_t src0 =
   8244                      _src[0].u32[_i];
   8245                   const int32_t src1 =
   8246                      _src[1].i32[_i];
   8247                   const int32_t src2 =
   8248                      _src[2].i32[_i];
   8249 
   8250                uint32_t dst;
   8251 
   8252 
   8253 unsigned base = src0;
   8254 int offset = src1, bits = src2;
   8255 if (bits == 0) {
   8256    dst = 0;
   8257 } else if (bits < 0 || offset < 0 || offset + bits > 32) {
   8258    dst = 0; /* undefined per the spec */
   8259 } else {
   8260    dst = (base >> offset) & ((1ull << bits) - 1);
   8261 }
   8262 
   8263 
   8264                _dst_val.u32[_i] = dst;
   8265          }
   8266 
   8267       break;
   8268    }
   8269    case 64: {
   8270 
   8271 
   8272 
   8273          for (unsigned _i = 0; _i < num_components; _i++) {
   8274                   const uint32_t src0 =
   8275                      _src[0].u32[_i];
   8276                   const int32_t src1 =
   8277                      _src[1].i32[_i];
   8278                   const int32_t src2 =
   8279                      _src[2].i32[_i];
   8280 
   8281                uint32_t dst;
   8282 
   8283 
   8284 unsigned base = src0;
   8285 int offset = src1, bits = src2;
   8286 if (bits == 0) {
   8287    dst = 0;
   8288 } else if (bits < 0 || offset < 0 || offset + bits > 32) {
   8289    dst = 0; /* undefined per the spec */
   8290 } else {
   8291    dst = (base >> offset) & ((1ull << bits) - 1);
   8292 }
   8293 
   8294 
   8295                _dst_val.u32[_i] = dst;
   8296          }
   8297 
   8298       break;
   8299    }
   8300 
   8301    default:
   8302       unreachable("unknown bit width");
   8303    }
   8304 
   8305    return _dst_val;
   8306 }
   8307 static nir_const_value
   8308 evaluate_udiv(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8309                  MAYBE_UNUSED nir_const_value *_src)
   8310 {
   8311    nir_const_value _dst_val = { {0, } };
   8312 
   8313    switch (bit_size) {
   8314    case 32: {
   8315 
   8316 
   8317 
   8318          for (unsigned _i = 0; _i < num_components; _i++) {
   8319                   const uint32_t src0 =
   8320                      _src[0].u32[_i];
   8321                   const uint32_t src1 =
   8322                      _src[1].u32[_i];
   8323 
   8324                uint32_t dst = src0 / src1;
   8325 
   8326                _dst_val.u32[_i] = dst;
   8327          }
   8328 
   8329       break;
   8330    }
   8331    case 64: {
   8332 
   8333 
   8334 
   8335          for (unsigned _i = 0; _i < num_components; _i++) {
   8336                   const uint64_t src0 =
   8337                      _src[0].u64[_i];
   8338                   const uint64_t src1 =
   8339                      _src[1].u64[_i];
   8340 
   8341                uint64_t dst = src0 / src1;
   8342 
   8343                _dst_val.u64[_i] = dst;
   8344          }
   8345 
   8346       break;
   8347    }
   8348 
   8349    default:
   8350       unreachable("unknown bit width");
   8351    }
   8352 
   8353    return _dst_val;
   8354 }
   8355 static nir_const_value
   8356 evaluate_ufind_msb(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8357                  MAYBE_UNUSED nir_const_value *_src)
   8358 {
   8359    nir_const_value _dst_val = { {0, } };
   8360 
   8361    switch (bit_size) {
   8362    case 32: {
   8363 
   8364 
   8365 
   8366          for (unsigned _i = 0; _i < num_components; _i++) {
   8367                   const uint32_t src0 =
   8368                      _src[0].u32[_i];
   8369 
   8370                int32_t dst;
   8371 
   8372 
   8373 dst = -1;
   8374 for (int bit = 31; bit > 0; bit--) {
   8375    if ((src0 >> bit) & 1) {
   8376       dst = bit;
   8377       break;
   8378    }
   8379 }
   8380 
   8381 
   8382                _dst_val.i32[_i] = dst;
   8383          }
   8384 
   8385       break;
   8386    }
   8387    case 64: {
   8388 
   8389 
   8390 
   8391          for (unsigned _i = 0; _i < num_components; _i++) {
   8392                   const uint32_t src0 =
   8393                      _src[0].u32[_i];
   8394 
   8395                int32_t dst;
   8396 
   8397 
   8398 dst = -1;
   8399 for (int bit = 31; bit > 0; bit--) {
   8400    if ((src0 >> bit) & 1) {
   8401       dst = bit;
   8402       break;
   8403    }
   8404 }
   8405 
   8406 
   8407                _dst_val.i32[_i] = dst;
   8408          }
   8409 
   8410       break;
   8411    }
   8412 
   8413    default:
   8414       unreachable("unknown bit width");
   8415    }
   8416 
   8417    return _dst_val;
   8418 }
   8419 static nir_const_value
   8420 evaluate_uge(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8421                  MAYBE_UNUSED nir_const_value *_src)
   8422 {
   8423    nir_const_value _dst_val = { {0, } };
   8424 
   8425    switch (bit_size) {
   8426    case 32: {
   8427 
   8428 
   8429 
   8430          for (unsigned _i = 0; _i < num_components; _i++) {
   8431                   const uint32_t src0 =
   8432                      _src[0].u32[_i];
   8433                   const uint32_t src1 =
   8434                      _src[1].u32[_i];
   8435 
   8436                bool32_t dst = src0 >= src1;
   8437 
   8438                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   8439          }
   8440 
   8441       break;
   8442    }
   8443    case 64: {
   8444 
   8445 
   8446 
   8447          for (unsigned _i = 0; _i < num_components; _i++) {
   8448                   const uint64_t src0 =
   8449                      _src[0].u64[_i];
   8450                   const uint64_t src1 =
   8451                      _src[1].u64[_i];
   8452 
   8453                bool32_t dst = src0 >= src1;
   8454 
   8455                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   8456          }
   8457 
   8458       break;
   8459    }
   8460 
   8461    default:
   8462       unreachable("unknown bit width");
   8463    }
   8464 
   8465    return _dst_val;
   8466 }
   8467 static nir_const_value
   8468 evaluate_ult(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8469                  MAYBE_UNUSED nir_const_value *_src)
   8470 {
   8471    nir_const_value _dst_val = { {0, } };
   8472 
   8473    switch (bit_size) {
   8474    case 32: {
   8475 
   8476 
   8477 
   8478          for (unsigned _i = 0; _i < num_components; _i++) {
   8479                   const uint32_t src0 =
   8480                      _src[0].u32[_i];
   8481                   const uint32_t src1 =
   8482                      _src[1].u32[_i];
   8483 
   8484                bool32_t dst = src0 < src1;
   8485 
   8486                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   8487          }
   8488 
   8489       break;
   8490    }
   8491    case 64: {
   8492 
   8493 
   8494 
   8495          for (unsigned _i = 0; _i < num_components; _i++) {
   8496                   const uint64_t src0 =
   8497                      _src[0].u64[_i];
   8498                   const uint64_t src1 =
   8499                      _src[1].u64[_i];
   8500 
   8501                bool32_t dst = src0 < src1;
   8502 
   8503                _dst_val.u32[_i] = dst ? NIR_TRUE : NIR_FALSE;
   8504          }
   8505 
   8506       break;
   8507    }
   8508 
   8509    default:
   8510       unreachable("unknown bit width");
   8511    }
   8512 
   8513    return _dst_val;
   8514 }
   8515 static nir_const_value
   8516 evaluate_umax(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8517                  MAYBE_UNUSED nir_const_value *_src)
   8518 {
   8519    nir_const_value _dst_val = { {0, } };
   8520 
   8521    switch (bit_size) {
   8522    case 32: {
   8523 
   8524 
   8525 
   8526          for (unsigned _i = 0; _i < num_components; _i++) {
   8527                   const uint32_t src0 =
   8528                      _src[0].u32[_i];
   8529                   const uint32_t src1 =
   8530                      _src[1].u32[_i];
   8531 
   8532                uint32_t dst = src1 > src0 ? src1 : src0;
   8533 
   8534                _dst_val.u32[_i] = dst;
   8535          }
   8536 
   8537       break;
   8538    }
   8539    case 64: {
   8540 
   8541 
   8542 
   8543          for (unsigned _i = 0; _i < num_components; _i++) {
   8544                   const uint64_t src0 =
   8545                      _src[0].u64[_i];
   8546                   const uint64_t src1 =
   8547                      _src[1].u64[_i];
   8548 
   8549                uint64_t dst = src1 > src0 ? src1 : src0;
   8550 
   8551                _dst_val.u64[_i] = dst;
   8552          }
   8553 
   8554       break;
   8555    }
   8556 
   8557    default:
   8558       unreachable("unknown bit width");
   8559    }
   8560 
   8561    return _dst_val;
   8562 }
   8563 static nir_const_value
   8564 evaluate_umax_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8565                  MAYBE_UNUSED nir_const_value *_src)
   8566 {
   8567    nir_const_value _dst_val = { {0, } };
   8568 
   8569    switch (bit_size) {
   8570    case 32: {
   8571 
   8572 
   8573 
   8574          for (unsigned _i = 0; _i < num_components; _i++) {
   8575                   const int32_t src0 =
   8576                      _src[0].i32[_i];
   8577                   const int32_t src1 =
   8578                      _src[1].i32[_i];
   8579 
   8580                int32_t dst;
   8581 
   8582 
   8583 dst = 0;
   8584 for (int i = 0; i < 32; i += 8) {
   8585    dst |= MAX2((src0 >> i) & 0xff, (src1 >> i) & 0xff) << i;
   8586 }
   8587 
   8588 
   8589                _dst_val.i32[_i] = dst;
   8590          }
   8591 
   8592       break;
   8593    }
   8594    case 64: {
   8595 
   8596 
   8597 
   8598          for (unsigned _i = 0; _i < num_components; _i++) {
   8599                   const int32_t src0 =
   8600                      _src[0].i32[_i];
   8601                   const int32_t src1 =
   8602                      _src[1].i32[_i];
   8603 
   8604                int32_t dst;
   8605 
   8606 
   8607 dst = 0;
   8608 for (int i = 0; i < 32; i += 8) {
   8609    dst |= MAX2((src0 >> i) & 0xff, (src1 >> i) & 0xff) << i;
   8610 }
   8611 
   8612 
   8613                _dst_val.i32[_i] = dst;
   8614          }
   8615 
   8616       break;
   8617    }
   8618 
   8619    default:
   8620       unreachable("unknown bit width");
   8621    }
   8622 
   8623    return _dst_val;
   8624 }
   8625 static nir_const_value
   8626 evaluate_umin(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8627                  MAYBE_UNUSED nir_const_value *_src)
   8628 {
   8629    nir_const_value _dst_val = { {0, } };
   8630 
   8631    switch (bit_size) {
   8632    case 32: {
   8633 
   8634 
   8635 
   8636          for (unsigned _i = 0; _i < num_components; _i++) {
   8637                   const uint32_t src0 =
   8638                      _src[0].u32[_i];
   8639                   const uint32_t src1 =
   8640                      _src[1].u32[_i];
   8641 
   8642                uint32_t dst = src1 > src0 ? src0 : src1;
   8643 
   8644                _dst_val.u32[_i] = dst;
   8645          }
   8646 
   8647       break;
   8648    }
   8649    case 64: {
   8650 
   8651 
   8652 
   8653          for (unsigned _i = 0; _i < num_components; _i++) {
   8654                   const uint64_t src0 =
   8655                      _src[0].u64[_i];
   8656                   const uint64_t src1 =
   8657                      _src[1].u64[_i];
   8658 
   8659                uint64_t dst = src1 > src0 ? src0 : src1;
   8660 
   8661                _dst_val.u64[_i] = dst;
   8662          }
   8663 
   8664       break;
   8665    }
   8666 
   8667    default:
   8668       unreachable("unknown bit width");
   8669    }
   8670 
   8671    return _dst_val;
   8672 }
   8673 static nir_const_value
   8674 evaluate_umin_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8675                  MAYBE_UNUSED nir_const_value *_src)
   8676 {
   8677    nir_const_value _dst_val = { {0, } };
   8678 
   8679    switch (bit_size) {
   8680    case 32: {
   8681 
   8682 
   8683 
   8684          for (unsigned _i = 0; _i < num_components; _i++) {
   8685                   const int32_t src0 =
   8686                      _src[0].i32[_i];
   8687                   const int32_t src1 =
   8688                      _src[1].i32[_i];
   8689 
   8690                int32_t dst;
   8691 
   8692 
   8693 dst = 0;
   8694 for (int i = 0; i < 32; i += 8) {
   8695    dst |= MIN2((src0 >> i) & 0xff, (src1 >> i) & 0xff) << i;
   8696 }
   8697 
   8698 
   8699                _dst_val.i32[_i] = dst;
   8700          }
   8701 
   8702       break;
   8703    }
   8704    case 64: {
   8705 
   8706 
   8707 
   8708          for (unsigned _i = 0; _i < num_components; _i++) {
   8709                   const int32_t src0 =
   8710                      _src[0].i32[_i];
   8711                   const int32_t src1 =
   8712                      _src[1].i32[_i];
   8713 
   8714                int32_t dst;
   8715 
   8716 
   8717 dst = 0;
   8718 for (int i = 0; i < 32; i += 8) {
   8719    dst |= MIN2((src0 >> i) & 0xff, (src1 >> i) & 0xff) << i;
   8720 }
   8721 
   8722 
   8723                _dst_val.i32[_i] = dst;
   8724          }
   8725 
   8726       break;
   8727    }
   8728 
   8729    default:
   8730       unreachable("unknown bit width");
   8731    }
   8732 
   8733    return _dst_val;
   8734 }
   8735 static nir_const_value
   8736 evaluate_umod(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8737                  MAYBE_UNUSED nir_const_value *_src)
   8738 {
   8739    nir_const_value _dst_val = { {0, } };
   8740 
   8741    switch (bit_size) {
   8742    case 32: {
   8743 
   8744 
   8745 
   8746          for (unsigned _i = 0; _i < num_components; _i++) {
   8747                   const uint32_t src0 =
   8748                      _src[0].u32[_i];
   8749                   const uint32_t src1 =
   8750                      _src[1].u32[_i];
   8751 
   8752                uint32_t dst = src1 == 0 ? 0 : src0 % src1;
   8753 
   8754                _dst_val.u32[_i] = dst;
   8755          }
   8756 
   8757       break;
   8758    }
   8759    case 64: {
   8760 
   8761 
   8762 
   8763          for (unsigned _i = 0; _i < num_components; _i++) {
   8764                   const uint64_t src0 =
   8765                      _src[0].u64[_i];
   8766                   const uint64_t src1 =
   8767                      _src[1].u64[_i];
   8768 
   8769                uint64_t dst = src1 == 0 ? 0 : src0 % src1;
   8770 
   8771                _dst_val.u64[_i] = dst;
   8772          }
   8773 
   8774       break;
   8775    }
   8776 
   8777    default:
   8778       unreachable("unknown bit width");
   8779    }
   8780 
   8781    return _dst_val;
   8782 }
   8783 static nir_const_value
   8784 evaluate_umul_high(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8785                  MAYBE_UNUSED nir_const_value *_src)
   8786 {
   8787    nir_const_value _dst_val = { {0, } };
   8788 
   8789    switch (bit_size) {
   8790    case 32: {
   8791 
   8792 
   8793 
   8794          for (unsigned _i = 0; _i < num_components; _i++) {
   8795                   const uint32_t src0 =
   8796                      _src[0].u32[_i];
   8797                   const uint32_t src1 =
   8798                      _src[1].u32[_i];
   8799 
   8800                uint32_t dst = (uint32_t)(((uint64_t) src0 * (uint64_t) src1) >> 32);
   8801 
   8802                _dst_val.u32[_i] = dst;
   8803          }
   8804 
   8805       break;
   8806    }
   8807    case 64: {
   8808 
   8809 
   8810 
   8811          for (unsigned _i = 0; _i < num_components; _i++) {
   8812                   const uint32_t src0 =
   8813                      _src[0].u32[_i];
   8814                   const uint32_t src1 =
   8815                      _src[1].u32[_i];
   8816 
   8817                uint32_t dst = (uint32_t)(((uint64_t) src0 * (uint64_t) src1) >> 32);
   8818 
   8819                _dst_val.u32[_i] = dst;
   8820          }
   8821 
   8822       break;
   8823    }
   8824 
   8825    default:
   8826       unreachable("unknown bit width");
   8827    }
   8828 
   8829    return _dst_val;
   8830 }
   8831 static nir_const_value
   8832 evaluate_umul_unorm_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8833                  MAYBE_UNUSED nir_const_value *_src)
   8834 {
   8835    nir_const_value _dst_val = { {0, } };
   8836 
   8837    switch (bit_size) {
   8838    case 32: {
   8839 
   8840 
   8841 
   8842          for (unsigned _i = 0; _i < num_components; _i++) {
   8843                   const int32_t src0 =
   8844                      _src[0].i32[_i];
   8845                   const int32_t src1 =
   8846                      _src[1].i32[_i];
   8847 
   8848                int32_t dst;
   8849 
   8850 
   8851 dst = 0;
   8852 for (int i = 0; i < 32; i += 8) {
   8853    int src0_chan = (src0 >> i) & 0xff;
   8854    int src1_chan = (src1 >> i) & 0xff;
   8855    dst |= ((src0_chan * src1_chan) / 255) << i;
   8856 }
   8857 
   8858 
   8859                _dst_val.i32[_i] = dst;
   8860          }
   8861 
   8862       break;
   8863    }
   8864    case 64: {
   8865 
   8866 
   8867 
   8868          for (unsigned _i = 0; _i < num_components; _i++) {
   8869                   const int32_t src0 =
   8870                      _src[0].i32[_i];
   8871                   const int32_t src1 =
   8872                      _src[1].i32[_i];
   8873 
   8874                int32_t dst;
   8875 
   8876 
   8877 dst = 0;
   8878 for (int i = 0; i < 32; i += 8) {
   8879    int src0_chan = (src0 >> i) & 0xff;
   8880    int src1_chan = (src1 >> i) & 0xff;
   8881    dst |= ((src0_chan * src1_chan) / 255) << i;
   8882 }
   8883 
   8884 
   8885                _dst_val.i32[_i] = dst;
   8886          }
   8887 
   8888       break;
   8889    }
   8890 
   8891    default:
   8892       unreachable("unknown bit width");
   8893    }
   8894 
   8895    return _dst_val;
   8896 }
   8897 static nir_const_value
   8898 evaluate_unpack_double_2x32(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8899                  MAYBE_UNUSED nir_const_value *_src)
   8900 {
   8901    nir_const_value _dst_val = { {0, } };
   8902 
   8903    switch (bit_size) {
   8904    case 32: {
   8905 
   8906 
   8907 
   8908          const struct uint64_vec src0 = {
   8909                _src[0].u64[0],
   8910             0,
   8911             0,
   8912             0,
   8913          };
   8914 
   8915          struct uint32_vec dst;
   8916 
   8917             dst.x = src0.x; dst.y = src0.x >> 32;
   8918 
   8919                _dst_val.u32[0] = dst.x;
   8920                _dst_val.u32[1] = dst.y;
   8921 
   8922       break;
   8923    }
   8924    case 64: {
   8925 
   8926 
   8927 
   8928          const struct uint64_vec src0 = {
   8929                _src[0].u64[0],
   8930             0,
   8931             0,
   8932             0,
   8933          };
   8934 
   8935          struct uint32_vec dst;
   8936 
   8937             dst.x = src0.x; dst.y = src0.x >> 32;
   8938 
   8939                _dst_val.u32[0] = dst.x;
   8940                _dst_val.u32[1] = dst.y;
   8941 
   8942       break;
   8943    }
   8944 
   8945    default:
   8946       unreachable("unknown bit width");
   8947    }
   8948 
   8949    return _dst_val;
   8950 }
   8951 static nir_const_value
   8952 evaluate_unpack_double_2x32_split_x(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8953                  MAYBE_UNUSED nir_const_value *_src)
   8954 {
   8955    nir_const_value _dst_val = { {0, } };
   8956 
   8957    switch (bit_size) {
   8958    case 32: {
   8959 
   8960 
   8961 
   8962          for (unsigned _i = 0; _i < num_components; _i++) {
   8963                   const uint64_t src0 =
   8964                      _src[0].u64[_i];
   8965 
   8966                uint32_t dst = src0;
   8967 
   8968                _dst_val.u32[_i] = dst;
   8969          }
   8970 
   8971       break;
   8972    }
   8973    case 64: {
   8974 
   8975 
   8976 
   8977          for (unsigned _i = 0; _i < num_components; _i++) {
   8978                   const uint64_t src0 =
   8979                      _src[0].u64[_i];
   8980 
   8981                uint32_t dst = src0;
   8982 
   8983                _dst_val.u32[_i] = dst;
   8984          }
   8985 
   8986       break;
   8987    }
   8988 
   8989    default:
   8990       unreachable("unknown bit width");
   8991    }
   8992 
   8993    return _dst_val;
   8994 }
   8995 static nir_const_value
   8996 evaluate_unpack_double_2x32_split_y(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   8997                  MAYBE_UNUSED nir_const_value *_src)
   8998 {
   8999    nir_const_value _dst_val = { {0, } };
   9000 
   9001    switch (bit_size) {
   9002    case 32: {
   9003 
   9004 
   9005 
   9006          for (unsigned _i = 0; _i < num_components; _i++) {
   9007                   const uint64_t src0 =
   9008                      _src[0].u64[_i];
   9009 
   9010                uint32_t dst = src0 >> 32;
   9011 
   9012                _dst_val.u32[_i] = dst;
   9013          }
   9014 
   9015       break;
   9016    }
   9017    case 64: {
   9018 
   9019 
   9020 
   9021          for (unsigned _i = 0; _i < num_components; _i++) {
   9022                   const uint64_t src0 =
   9023                      _src[0].u64[_i];
   9024 
   9025                uint32_t dst = src0 >> 32;
   9026 
   9027                _dst_val.u32[_i] = dst;
   9028          }
   9029 
   9030       break;
   9031    }
   9032 
   9033    default:
   9034       unreachable("unknown bit width");
   9035    }
   9036 
   9037    return _dst_val;
   9038 }
   9039 static nir_const_value
   9040 evaluate_unpack_half_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9041                  MAYBE_UNUSED nir_const_value *_src)
   9042 {
   9043    nir_const_value _dst_val = { {0, } };
   9044 
   9045    switch (bit_size) {
   9046    case 32: {
   9047 
   9048 
   9049 
   9050          const struct uint32_vec src0 = {
   9051                _src[0].u32[0],
   9052             0,
   9053             0,
   9054             0,
   9055          };
   9056 
   9057          struct float32_vec dst;
   9058 
   9059 
   9060 dst.x = unpack_half_1x16((uint16_t)(src0.x & 0xffff));
   9061 dst.y = unpack_half_1x16((uint16_t)(src0.x << 16));
   9062 
   9063 
   9064                _dst_val.f32[0] = dst.x;
   9065                _dst_val.f32[1] = dst.y;
   9066 
   9067       break;
   9068    }
   9069    case 64: {
   9070 
   9071 
   9072 
   9073          const struct uint32_vec src0 = {
   9074                _src[0].u32[0],
   9075             0,
   9076             0,
   9077             0,
   9078          };
   9079 
   9080          struct float32_vec dst;
   9081 
   9082 
   9083 dst.x = unpack_half_1x16((uint16_t)(src0.x & 0xffff));
   9084 dst.y = unpack_half_1x16((uint16_t)(src0.x << 16));
   9085 
   9086 
   9087                _dst_val.f32[0] = dst.x;
   9088                _dst_val.f32[1] = dst.y;
   9089 
   9090       break;
   9091    }
   9092 
   9093    default:
   9094       unreachable("unknown bit width");
   9095    }
   9096 
   9097    return _dst_val;
   9098 }
   9099 static nir_const_value
   9100 evaluate_unpack_half_2x16_split_x(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9101                  MAYBE_UNUSED nir_const_value *_src)
   9102 {
   9103    nir_const_value _dst_val = { {0, } };
   9104 
   9105    switch (bit_size) {
   9106    case 32: {
   9107 
   9108 
   9109 
   9110          const struct uint32_vec src0 = {
   9111                _src[0].u32[0],
   9112             0,
   9113             0,
   9114             0,
   9115          };
   9116 
   9117          struct float32_vec dst;
   9118 
   9119             dst.x = dst.y = dst.z = dst.w = unpack_half_1x16((uint16_t)(src0.x & 0xffff));
   9120 
   9121                _dst_val.f32[0] = dst.x;
   9122 
   9123       break;
   9124    }
   9125    case 64: {
   9126 
   9127 
   9128 
   9129          const struct uint32_vec src0 = {
   9130                _src[0].u32[0],
   9131             0,
   9132             0,
   9133             0,
   9134          };
   9135 
   9136          struct float32_vec dst;
   9137 
   9138             dst.x = dst.y = dst.z = dst.w = unpack_half_1x16((uint16_t)(src0.x & 0xffff));
   9139 
   9140                _dst_val.f32[0] = dst.x;
   9141 
   9142       break;
   9143    }
   9144 
   9145    default:
   9146       unreachable("unknown bit width");
   9147    }
   9148 
   9149    return _dst_val;
   9150 }
   9151 static nir_const_value
   9152 evaluate_unpack_half_2x16_split_y(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9153                  MAYBE_UNUSED nir_const_value *_src)
   9154 {
   9155    nir_const_value _dst_val = { {0, } };
   9156 
   9157    switch (bit_size) {
   9158    case 32: {
   9159 
   9160 
   9161 
   9162          const struct uint32_vec src0 = {
   9163                _src[0].u32[0],
   9164             0,
   9165             0,
   9166             0,
   9167          };
   9168 
   9169          struct float32_vec dst;
   9170 
   9171             dst.x = dst.y = dst.z = dst.w = unpack_half_1x16((uint16_t)(src0.x >> 16));
   9172 
   9173                _dst_val.f32[0] = dst.x;
   9174 
   9175       break;
   9176    }
   9177    case 64: {
   9178 
   9179 
   9180 
   9181          const struct uint32_vec src0 = {
   9182                _src[0].u32[0],
   9183             0,
   9184             0,
   9185             0,
   9186          };
   9187 
   9188          struct float32_vec dst;
   9189 
   9190             dst.x = dst.y = dst.z = dst.w = unpack_half_1x16((uint16_t)(src0.x >> 16));
   9191 
   9192                _dst_val.f32[0] = dst.x;
   9193 
   9194       break;
   9195    }
   9196 
   9197    default:
   9198       unreachable("unknown bit width");
   9199    }
   9200 
   9201    return _dst_val;
   9202 }
   9203 static nir_const_value
   9204 evaluate_unpack_snorm_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9205                  MAYBE_UNUSED nir_const_value *_src)
   9206 {
   9207    nir_const_value _dst_val = { {0, } };
   9208 
   9209    switch (bit_size) {
   9210    case 32: {
   9211 
   9212 
   9213 
   9214          const struct uint32_vec src0 = {
   9215                _src[0].u32[0],
   9216             0,
   9217             0,
   9218             0,
   9219          };
   9220 
   9221          struct float32_vec dst;
   9222 
   9223 
   9224 dst.x = unpack_snorm_1x16((uint16_t)(src0.x & 0xffff));
   9225 dst.y = unpack_snorm_1x16((uint16_t)(src0.x << 16));
   9226 
   9227 
   9228                _dst_val.f32[0] = dst.x;
   9229                _dst_val.f32[1] = dst.y;
   9230 
   9231       break;
   9232    }
   9233    case 64: {
   9234 
   9235 
   9236 
   9237          const struct uint32_vec src0 = {
   9238                _src[0].u32[0],
   9239             0,
   9240             0,
   9241             0,
   9242          };
   9243 
   9244          struct float32_vec dst;
   9245 
   9246 
   9247 dst.x = unpack_snorm_1x16((uint16_t)(src0.x & 0xffff));
   9248 dst.y = unpack_snorm_1x16((uint16_t)(src0.x << 16));
   9249 
   9250 
   9251                _dst_val.f32[0] = dst.x;
   9252                _dst_val.f32[1] = dst.y;
   9253 
   9254       break;
   9255    }
   9256 
   9257    default:
   9258       unreachable("unknown bit width");
   9259    }
   9260 
   9261    return _dst_val;
   9262 }
   9263 static nir_const_value
   9264 evaluate_unpack_snorm_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9265                  MAYBE_UNUSED nir_const_value *_src)
   9266 {
   9267    nir_const_value _dst_val = { {0, } };
   9268 
   9269    switch (bit_size) {
   9270    case 32: {
   9271 
   9272 
   9273 
   9274          const struct uint32_vec src0 = {
   9275                _src[0].u32[0],
   9276             0,
   9277             0,
   9278             0,
   9279          };
   9280 
   9281          struct float32_vec dst;
   9282 
   9283 
   9284 dst.x = unpack_snorm_1x8((uint8_t)(src0.x & 0xff));
   9285 dst.y = unpack_snorm_1x8((uint8_t)((src0.x >> 8) & 0xff));
   9286 dst.z = unpack_snorm_1x8((uint8_t)((src0.x >> 16) & 0xff));
   9287 dst.w = unpack_snorm_1x8((uint8_t)(src0.x >> 24));
   9288 
   9289 
   9290                _dst_val.f32[0] = dst.x;
   9291                _dst_val.f32[1] = dst.y;
   9292                _dst_val.f32[2] = dst.z;
   9293                _dst_val.f32[3] = dst.w;
   9294 
   9295       break;
   9296    }
   9297    case 64: {
   9298 
   9299 
   9300 
   9301          const struct uint32_vec src0 = {
   9302                _src[0].u32[0],
   9303             0,
   9304             0,
   9305             0,
   9306          };
   9307 
   9308          struct float32_vec dst;
   9309 
   9310 
   9311 dst.x = unpack_snorm_1x8((uint8_t)(src0.x & 0xff));
   9312 dst.y = unpack_snorm_1x8((uint8_t)((src0.x >> 8) & 0xff));
   9313 dst.z = unpack_snorm_1x8((uint8_t)((src0.x >> 16) & 0xff));
   9314 dst.w = unpack_snorm_1x8((uint8_t)(src0.x >> 24));
   9315 
   9316 
   9317                _dst_val.f32[0] = dst.x;
   9318                _dst_val.f32[1] = dst.y;
   9319                _dst_val.f32[2] = dst.z;
   9320                _dst_val.f32[3] = dst.w;
   9321 
   9322       break;
   9323    }
   9324 
   9325    default:
   9326       unreachable("unknown bit width");
   9327    }
   9328 
   9329    return _dst_val;
   9330 }
   9331 static nir_const_value
   9332 evaluate_unpack_unorm_2x16(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9333                  MAYBE_UNUSED nir_const_value *_src)
   9334 {
   9335    nir_const_value _dst_val = { {0, } };
   9336 
   9337    switch (bit_size) {
   9338    case 32: {
   9339 
   9340 
   9341 
   9342          const struct uint32_vec src0 = {
   9343                _src[0].u32[0],
   9344             0,
   9345             0,
   9346             0,
   9347          };
   9348 
   9349          struct float32_vec dst;
   9350 
   9351 
   9352 dst.x = unpack_unorm_1x16((uint16_t)(src0.x & 0xffff));
   9353 dst.y = unpack_unorm_1x16((uint16_t)(src0.x << 16));
   9354 
   9355 
   9356                _dst_val.f32[0] = dst.x;
   9357                _dst_val.f32[1] = dst.y;
   9358 
   9359       break;
   9360    }
   9361    case 64: {
   9362 
   9363 
   9364 
   9365          const struct uint32_vec src0 = {
   9366                _src[0].u32[0],
   9367             0,
   9368             0,
   9369             0,
   9370          };
   9371 
   9372          struct float32_vec dst;
   9373 
   9374 
   9375 dst.x = unpack_unorm_1x16((uint16_t)(src0.x & 0xffff));
   9376 dst.y = unpack_unorm_1x16((uint16_t)(src0.x << 16));
   9377 
   9378 
   9379                _dst_val.f32[0] = dst.x;
   9380                _dst_val.f32[1] = dst.y;
   9381 
   9382       break;
   9383    }
   9384 
   9385    default:
   9386       unreachable("unknown bit width");
   9387    }
   9388 
   9389    return _dst_val;
   9390 }
   9391 static nir_const_value
   9392 evaluate_unpack_unorm_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9393                  MAYBE_UNUSED nir_const_value *_src)
   9394 {
   9395    nir_const_value _dst_val = { {0, } };
   9396 
   9397    switch (bit_size) {
   9398    case 32: {
   9399 
   9400 
   9401 
   9402          const struct uint32_vec src0 = {
   9403                _src[0].u32[0],
   9404             0,
   9405             0,
   9406             0,
   9407          };
   9408 
   9409          struct float32_vec dst;
   9410 
   9411 
   9412 dst.x = unpack_unorm_1x8((uint8_t)(src0.x & 0xff));
   9413 dst.y = unpack_unorm_1x8((uint8_t)((src0.x >> 8) & 0xff));
   9414 dst.z = unpack_unorm_1x8((uint8_t)((src0.x >> 16) & 0xff));
   9415 dst.w = unpack_unorm_1x8((uint8_t)(src0.x >> 24));
   9416 
   9417 
   9418                _dst_val.f32[0] = dst.x;
   9419                _dst_val.f32[1] = dst.y;
   9420                _dst_val.f32[2] = dst.z;
   9421                _dst_val.f32[3] = dst.w;
   9422 
   9423       break;
   9424    }
   9425    case 64: {
   9426 
   9427 
   9428 
   9429          const struct uint32_vec src0 = {
   9430                _src[0].u32[0],
   9431             0,
   9432             0,
   9433             0,
   9434          };
   9435 
   9436          struct float32_vec dst;
   9437 
   9438 
   9439 dst.x = unpack_unorm_1x8((uint8_t)(src0.x & 0xff));
   9440 dst.y = unpack_unorm_1x8((uint8_t)((src0.x >> 8) & 0xff));
   9441 dst.z = unpack_unorm_1x8((uint8_t)((src0.x >> 16) & 0xff));
   9442 dst.w = unpack_unorm_1x8((uint8_t)(src0.x >> 24));
   9443 
   9444 
   9445                _dst_val.f32[0] = dst.x;
   9446                _dst_val.f32[1] = dst.y;
   9447                _dst_val.f32[2] = dst.z;
   9448                _dst_val.f32[3] = dst.w;
   9449 
   9450       break;
   9451    }
   9452 
   9453    default:
   9454       unreachable("unknown bit width");
   9455    }
   9456 
   9457    return _dst_val;
   9458 }
   9459 static nir_const_value
   9460 evaluate_usadd_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9461                  MAYBE_UNUSED nir_const_value *_src)
   9462 {
   9463    nir_const_value _dst_val = { {0, } };
   9464 
   9465    switch (bit_size) {
   9466    case 32: {
   9467 
   9468 
   9469 
   9470          for (unsigned _i = 0; _i < num_components; _i++) {
   9471                   const int32_t src0 =
   9472                      _src[0].i32[_i];
   9473                   const int32_t src1 =
   9474                      _src[1].i32[_i];
   9475 
   9476                int32_t dst;
   9477 
   9478 
   9479 dst = 0;
   9480 for (int i = 0; i < 32; i += 8) {
   9481    dst |= MIN2(((src0 >> i) & 0xff) + ((src1 >> i) & 0xff), 0xff) << i;
   9482 }
   9483 
   9484 
   9485                _dst_val.i32[_i] = dst;
   9486          }
   9487 
   9488       break;
   9489    }
   9490    case 64: {
   9491 
   9492 
   9493 
   9494          for (unsigned _i = 0; _i < num_components; _i++) {
   9495                   const int32_t src0 =
   9496                      _src[0].i32[_i];
   9497                   const int32_t src1 =
   9498                      _src[1].i32[_i];
   9499 
   9500                int32_t dst;
   9501 
   9502 
   9503 dst = 0;
   9504 for (int i = 0; i < 32; i += 8) {
   9505    dst |= MIN2(((src0 >> i) & 0xff) + ((src1 >> i) & 0xff), 0xff) << i;
   9506 }
   9507 
   9508 
   9509                _dst_val.i32[_i] = dst;
   9510          }
   9511 
   9512       break;
   9513    }
   9514 
   9515    default:
   9516       unreachable("unknown bit width");
   9517    }
   9518 
   9519    return _dst_val;
   9520 }
   9521 static nir_const_value
   9522 evaluate_ushr(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9523                  MAYBE_UNUSED nir_const_value *_src)
   9524 {
   9525    nir_const_value _dst_val = { {0, } };
   9526 
   9527    switch (bit_size) {
   9528    case 32: {
   9529 
   9530 
   9531 
   9532          for (unsigned _i = 0; _i < num_components; _i++) {
   9533                   const uint32_t src0 =
   9534                      _src[0].u32[_i];
   9535                   const uint32_t src1 =
   9536                      _src[1].u32[_i];
   9537 
   9538                uint32_t dst = src0 >> src1;
   9539 
   9540                _dst_val.u32[_i] = dst;
   9541          }
   9542 
   9543       break;
   9544    }
   9545    case 64: {
   9546 
   9547 
   9548 
   9549          for (unsigned _i = 0; _i < num_components; _i++) {
   9550                   const uint64_t src0 =
   9551                      _src[0].u64[_i];
   9552                   const uint64_t src1 =
   9553                      _src[1].u64[_i];
   9554 
   9555                uint64_t dst = src0 >> src1;
   9556 
   9557                _dst_val.u64[_i] = dst;
   9558          }
   9559 
   9560       break;
   9561    }
   9562 
   9563    default:
   9564       unreachable("unknown bit width");
   9565    }
   9566 
   9567    return _dst_val;
   9568 }
   9569 static nir_const_value
   9570 evaluate_ussub_4x8(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9571                  MAYBE_UNUSED nir_const_value *_src)
   9572 {
   9573    nir_const_value _dst_val = { {0, } };
   9574 
   9575    switch (bit_size) {
   9576    case 32: {
   9577 
   9578 
   9579 
   9580          for (unsigned _i = 0; _i < num_components; _i++) {
   9581                   const int32_t src0 =
   9582                      _src[0].i32[_i];
   9583                   const int32_t src1 =
   9584                      _src[1].i32[_i];
   9585 
   9586                int32_t dst;
   9587 
   9588 
   9589 dst = 0;
   9590 for (int i = 0; i < 32; i += 8) {
   9591    int src0_chan = (src0 >> i) & 0xff;
   9592    int src1_chan = (src1 >> i) & 0xff;
   9593    if (src0_chan > src1_chan)
   9594       dst |= (src0_chan - src1_chan) << i;
   9595 }
   9596 
   9597 
   9598                _dst_val.i32[_i] = dst;
   9599          }
   9600 
   9601       break;
   9602    }
   9603    case 64: {
   9604 
   9605 
   9606 
   9607          for (unsigned _i = 0; _i < num_components; _i++) {
   9608                   const int32_t src0 =
   9609                      _src[0].i32[_i];
   9610                   const int32_t src1 =
   9611                      _src[1].i32[_i];
   9612 
   9613                int32_t dst;
   9614 
   9615 
   9616 dst = 0;
   9617 for (int i = 0; i < 32; i += 8) {
   9618    int src0_chan = (src0 >> i) & 0xff;
   9619    int src1_chan = (src1 >> i) & 0xff;
   9620    if (src0_chan > src1_chan)
   9621       dst |= (src0_chan - src1_chan) << i;
   9622 }
   9623 
   9624 
   9625                _dst_val.i32[_i] = dst;
   9626          }
   9627 
   9628       break;
   9629    }
   9630 
   9631    default:
   9632       unreachable("unknown bit width");
   9633    }
   9634 
   9635    return _dst_val;
   9636 }
   9637 static nir_const_value
   9638 evaluate_usub_borrow(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9639                  MAYBE_UNUSED nir_const_value *_src)
   9640 {
   9641    nir_const_value _dst_val = { {0, } };
   9642 
   9643    switch (bit_size) {
   9644    case 32: {
   9645 
   9646 
   9647 
   9648          for (unsigned _i = 0; _i < num_components; _i++) {
   9649                   const uint32_t src0 =
   9650                      _src[0].u32[_i];
   9651                   const uint32_t src1 =
   9652                      _src[1].u32[_i];
   9653 
   9654                uint32_t dst = src0 < src1;
   9655 
   9656                _dst_val.u32[_i] = dst;
   9657          }
   9658 
   9659       break;
   9660    }
   9661    case 64: {
   9662 
   9663 
   9664 
   9665          for (unsigned _i = 0; _i < num_components; _i++) {
   9666                   const uint64_t src0 =
   9667                      _src[0].u64[_i];
   9668                   const uint64_t src1 =
   9669                      _src[1].u64[_i];
   9670 
   9671                uint64_t dst = src0 < src1;
   9672 
   9673                _dst_val.u64[_i] = dst;
   9674          }
   9675 
   9676       break;
   9677    }
   9678 
   9679    default:
   9680       unreachable("unknown bit width");
   9681    }
   9682 
   9683    return _dst_val;
   9684 }
   9685 static nir_const_value
   9686 evaluate_vec2(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9687                  MAYBE_UNUSED nir_const_value *_src)
   9688 {
   9689    nir_const_value _dst_val = { {0, } };
   9690 
   9691    switch (bit_size) {
   9692    case 32: {
   9693 
   9694 
   9695 
   9696          const struct uint32_vec src0 = {
   9697                _src[0].u32[0],
   9698             0,
   9699             0,
   9700             0,
   9701          };
   9702 
   9703          const struct uint32_vec src1 = {
   9704                _src[1].u32[0],
   9705             0,
   9706             0,
   9707             0,
   9708          };
   9709 
   9710          struct uint32_vec dst;
   9711 
   9712 
   9713 dst.x = src0.x;
   9714 dst.y = src1.x;
   9715 
   9716 
   9717                _dst_val.u32[0] = dst.x;
   9718                _dst_val.u32[1] = dst.y;
   9719 
   9720       break;
   9721    }
   9722    case 64: {
   9723 
   9724 
   9725 
   9726          const struct uint64_vec src0 = {
   9727                _src[0].u64[0],
   9728             0,
   9729             0,
   9730             0,
   9731          };
   9732 
   9733          const struct uint64_vec src1 = {
   9734                _src[1].u64[0],
   9735             0,
   9736             0,
   9737             0,
   9738          };
   9739 
   9740          struct uint64_vec dst;
   9741 
   9742 
   9743 dst.x = src0.x;
   9744 dst.y = src1.x;
   9745 
   9746 
   9747                _dst_val.u64[0] = dst.x;
   9748                _dst_val.u64[1] = dst.y;
   9749 
   9750       break;
   9751    }
   9752 
   9753    default:
   9754       unreachable("unknown bit width");
   9755    }
   9756 
   9757    return _dst_val;
   9758 }
   9759 static nir_const_value
   9760 evaluate_vec3(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9761                  MAYBE_UNUSED nir_const_value *_src)
   9762 {
   9763    nir_const_value _dst_val = { {0, } };
   9764 
   9765    switch (bit_size) {
   9766    case 32: {
   9767 
   9768 
   9769 
   9770          const struct uint32_vec src0 = {
   9771                _src[0].u32[0],
   9772             0,
   9773             0,
   9774             0,
   9775          };
   9776 
   9777          const struct uint32_vec src1 = {
   9778                _src[1].u32[0],
   9779             0,
   9780             0,
   9781             0,
   9782          };
   9783 
   9784          const struct uint32_vec src2 = {
   9785                _src[2].u32[0],
   9786             0,
   9787             0,
   9788             0,
   9789          };
   9790 
   9791          struct uint32_vec dst;
   9792 
   9793 
   9794 dst.x = src0.x;
   9795 dst.y = src1.x;
   9796 dst.z = src2.x;
   9797 
   9798 
   9799                _dst_val.u32[0] = dst.x;
   9800                _dst_val.u32[1] = dst.y;
   9801                _dst_val.u32[2] = dst.z;
   9802 
   9803       break;
   9804    }
   9805    case 64: {
   9806 
   9807 
   9808 
   9809          const struct uint64_vec src0 = {
   9810                _src[0].u64[0],
   9811             0,
   9812             0,
   9813             0,
   9814          };
   9815 
   9816          const struct uint64_vec src1 = {
   9817                _src[1].u64[0],
   9818             0,
   9819             0,
   9820             0,
   9821          };
   9822 
   9823          const struct uint64_vec src2 = {
   9824                _src[2].u64[0],
   9825             0,
   9826             0,
   9827             0,
   9828          };
   9829 
   9830          struct uint64_vec dst;
   9831 
   9832 
   9833 dst.x = src0.x;
   9834 dst.y = src1.x;
   9835 dst.z = src2.x;
   9836 
   9837 
   9838                _dst_val.u64[0] = dst.x;
   9839                _dst_val.u64[1] = dst.y;
   9840                _dst_val.u64[2] = dst.z;
   9841 
   9842       break;
   9843    }
   9844 
   9845    default:
   9846       unreachable("unknown bit width");
   9847    }
   9848 
   9849    return _dst_val;
   9850 }
   9851 static nir_const_value
   9852 evaluate_vec4(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
   9853                  MAYBE_UNUSED nir_const_value *_src)
   9854 {
   9855    nir_const_value _dst_val = { {0, } };
   9856 
   9857    switch (bit_size) {
   9858    case 32: {
   9859 
   9860 
   9861 
   9862          const struct uint32_vec src0 = {
   9863                _src[0].u32[0],
   9864             0,
   9865             0,
   9866             0,
   9867          };
   9868 
   9869          const struct uint32_vec src1 = {
   9870                _src[1].u32[0],
   9871             0,
   9872             0,
   9873             0,
   9874          };
   9875 
   9876          const struct uint32_vec src2 = {
   9877                _src[2].u32[0],
   9878             0,
   9879             0,
   9880             0,
   9881          };
   9882 
   9883          const struct uint32_vec src3 = {
   9884                _src[3].u32[0],
   9885             0,
   9886             0,
   9887             0,
   9888          };
   9889 
   9890          struct uint32_vec dst;
   9891 
   9892 
   9893 dst.x = src0.x;
   9894 dst.y = src1.x;
   9895 dst.z = src2.x;
   9896 dst.w = src3.x;
   9897 
   9898 
   9899                _dst_val.u32[0] = dst.x;
   9900                _dst_val.u32[1] = dst.y;
   9901                _dst_val.u32[2] = dst.z;
   9902                _dst_val.u32[3] = dst.w;
   9903 
   9904       break;
   9905    }
   9906    case 64: {
   9907 
   9908 
   9909 
   9910          const struct uint64_vec src0 = {
   9911                _src[0].u64[0],
   9912             0,
   9913             0,
   9914             0,
   9915          };
   9916 
   9917          const struct uint64_vec src1 = {
   9918                _src[1].u64[0],
   9919             0,
   9920             0,
   9921             0,
   9922          };
   9923 
   9924          const struct uint64_vec src2 = {
   9925                _src[2].u64[0],
   9926             0,
   9927             0,
   9928             0,
   9929          };
   9930 
   9931          const struct uint64_vec src3 = {
   9932                _src[3].u64[0],
   9933             0,
   9934             0,
   9935             0,
   9936          };
   9937 
   9938          struct uint64_vec dst;
   9939 
   9940 
   9941 dst.x = src0.x;
   9942 dst.y = src1.x;
   9943 dst.z = src2.x;
   9944 dst.w = src3.x;
   9945 
   9946 
   9947                _dst_val.u64[0] = dst.x;
   9948                _dst_val.u64[1] = dst.y;
   9949                _dst_val.u64[2] = dst.z;
   9950                _dst_val.u64[3] = dst.w;
   9951 
   9952       break;
   9953    }
   9954 
   9955    default:
   9956       unreachable("unknown bit width");
   9957    }
   9958 
   9959    return _dst_val;
   9960 }
   9961 
   9962 nir_const_value
   9963 nir_eval_const_opcode(nir_op op, unsigned num_components,
   9964                       unsigned bit_width, nir_const_value *src)
   9965 {
   9966    switch (op) {
   9967    case nir_op_b2f:
   9968       return evaluate_b2f(num_components, bit_width, src);
   9969    case nir_op_b2i:
   9970       return evaluate_b2i(num_components, bit_width, src);
   9971    case nir_op_ball_fequal2:
   9972       return evaluate_ball_fequal2(num_components, bit_width, src);
   9973    case nir_op_ball_fequal3:
   9974       return evaluate_ball_fequal3(num_components, bit_width, src);
   9975    case nir_op_ball_fequal4:
   9976       return evaluate_ball_fequal4(num_components, bit_width, src);
   9977    case nir_op_ball_iequal2:
   9978       return evaluate_ball_iequal2(num_components, bit_width, src);
   9979    case nir_op_ball_iequal3:
   9980       return evaluate_ball_iequal3(num_components, bit_width, src);
   9981    case nir_op_ball_iequal4:
   9982       return evaluate_ball_iequal4(num_components, bit_width, src);
   9983    case nir_op_bany_fnequal2:
   9984       return evaluate_bany_fnequal2(num_components, bit_width, src);
   9985    case nir_op_bany_fnequal3:
   9986       return evaluate_bany_fnequal3(num_components, bit_width, src);
   9987    case nir_op_bany_fnequal4:
   9988       return evaluate_bany_fnequal4(num_components, bit_width, src);
   9989    case nir_op_bany_inequal2:
   9990       return evaluate_bany_inequal2(num_components, bit_width, src);
   9991    case nir_op_bany_inequal3:
   9992       return evaluate_bany_inequal3(num_components, bit_width, src);
   9993    case nir_op_bany_inequal4:
   9994       return evaluate_bany_inequal4(num_components, bit_width, src);
   9995    case nir_op_bcsel:
   9996       return evaluate_bcsel(num_components, bit_width, src);
   9997    case nir_op_bfi:
   9998       return evaluate_bfi(num_components, bit_width, src);
   9999    case nir_op_bfm:
   10000       return evaluate_bfm(num_components, bit_width, src);
   10001    case nir_op_bit_count:
   10002       return evaluate_bit_count(num_components, bit_width, src);
   10003    case nir_op_bitfield_insert:
   10004       return evaluate_bitfield_insert(num_components, bit_width, src);
   10005    case nir_op_bitfield_reverse:
   10006       return evaluate_bitfield_reverse(num_components, bit_width, src);
   10007    case nir_op_d2b:
   10008       return evaluate_d2b(num_components, bit_width, src);
   10009    case nir_op_d2f:
   10010       return evaluate_d2f(num_components, bit_width, src);
   10011    case nir_op_d2i:
   10012       return evaluate_d2i(num_components, bit_width, src);
   10013    case nir_op_d2u:
   10014       return evaluate_d2u(num_components, bit_width, src);
   10015    case nir_op_extract_i16:
   10016       return evaluate_extract_i16(num_components, bit_width, src);
   10017    case nir_op_extract_i8:
   10018       return evaluate_extract_i8(num_components, bit_width, src);
   10019    case nir_op_extract_u16:
   10020       return evaluate_extract_u16(num_components, bit_width, src);
   10021    case nir_op_extract_u8:
   10022       return evaluate_extract_u8(num_components, bit_width, src);
   10023    case nir_op_f2b:
   10024       return evaluate_f2b(num_components, bit_width, src);
   10025    case nir_op_f2d:
   10026       return evaluate_f2d(num_components, bit_width, src);
   10027    case nir_op_f2i:
   10028       return evaluate_f2i(num_components, bit_width, src);
   10029    case nir_op_f2u:
   10030       return evaluate_f2u(num_components, bit_width, src);
   10031    case nir_op_fabs:
   10032       return evaluate_fabs(num_components, bit_width, src);
   10033    case nir_op_fadd:
   10034       return evaluate_fadd(num_components, bit_width, src);
   10035    case nir_op_fall_equal2:
   10036       return evaluate_fall_equal2(num_components, bit_width, src);
   10037    case nir_op_fall_equal3:
   10038       return evaluate_fall_equal3(num_components, bit_width, src);
   10039    case nir_op_fall_equal4:
   10040       return evaluate_fall_equal4(num_components, bit_width, src);
   10041    case nir_op_fand:
   10042       return evaluate_fand(num_components, bit_width, src);
   10043    case nir_op_fany_nequal2:
   10044       return evaluate_fany_nequal2(num_components, bit_width, src);
   10045    case nir_op_fany_nequal3:
   10046       return evaluate_fany_nequal3(num_components, bit_width, src);
   10047    case nir_op_fany_nequal4:
   10048       return evaluate_fany_nequal4(num_components, bit_width, src);
   10049    case nir_op_fceil:
   10050       return evaluate_fceil(num_components, bit_width, src);
   10051    case nir_op_fcos:
   10052       return evaluate_fcos(num_components, bit_width, src);
   10053    case nir_op_fcsel:
   10054       return evaluate_fcsel(num_components, bit_width, src);
   10055    case nir_op_fddx:
   10056       return evaluate_fddx(num_components, bit_width, src);
   10057    case nir_op_fddx_coarse:
   10058       return evaluate_fddx_coarse(num_components, bit_width, src);
   10059    case nir_op_fddx_fine:
   10060       return evaluate_fddx_fine(num_components, bit_width, src);
   10061    case nir_op_fddy:
   10062       return evaluate_fddy(num_components, bit_width, src);
   10063    case nir_op_fddy_coarse:
   10064       return evaluate_fddy_coarse(num_components, bit_width, src);
   10065    case nir_op_fddy_fine:
   10066       return evaluate_fddy_fine(num_components, bit_width, src);
   10067    case nir_op_fdiv:
   10068       return evaluate_fdiv(num_components, bit_width, src);
   10069    case nir_op_fdot2:
   10070       return evaluate_fdot2(num_components, bit_width, src);
   10071    case nir_op_fdot3:
   10072       return evaluate_fdot3(num_components, bit_width, src);
   10073    case nir_op_fdot4:
   10074       return evaluate_fdot4(num_components, bit_width, src);
   10075    case nir_op_fdot_replicated2:
   10076       return evaluate_fdot_replicated2(num_components, bit_width, src);
   10077    case nir_op_fdot_replicated3:
   10078       return evaluate_fdot_replicated3(num_components, bit_width, src);
   10079    case nir_op_fdot_replicated4:
   10080       return evaluate_fdot_replicated4(num_components, bit_width, src);
   10081    case nir_op_fdph:
   10082       return evaluate_fdph(num_components, bit_width, src);
   10083    case nir_op_fdph_replicated:
   10084       return evaluate_fdph_replicated(num_components, bit_width, src);
   10085    case nir_op_feq:
   10086       return evaluate_feq(num_components, bit_width, src);
   10087    case nir_op_fexp2:
   10088       return evaluate_fexp2(num_components, bit_width, src);
   10089    case nir_op_ffloor:
   10090       return evaluate_ffloor(num_components, bit_width, src);
   10091    case nir_op_ffma:
   10092       return evaluate_ffma(num_components, bit_width, src);
   10093    case nir_op_ffract:
   10094       return evaluate_ffract(num_components, bit_width, src);
   10095    case nir_op_fge:
   10096       return evaluate_fge(num_components, bit_width, src);
   10097    case nir_op_find_lsb:
   10098       return evaluate_find_lsb(num_components, bit_width, src);
   10099    case nir_op_flog2:
   10100       return evaluate_flog2(num_components, bit_width, src);
   10101    case nir_op_flrp:
   10102       return evaluate_flrp(num_components, bit_width, src);
   10103    case nir_op_flt:
   10104       return evaluate_flt(num_components, bit_width, src);
   10105    case nir_op_fmax:
   10106       return evaluate_fmax(num_components, bit_width, src);
   10107    case nir_op_fmin:
   10108       return evaluate_fmin(num_components, bit_width, src);
   10109    case nir_op_fmod:
   10110       return evaluate_fmod(num_components, bit_width, src);
   10111    case nir_op_fmov:
   10112       return evaluate_fmov(num_components, bit_width, src);
   10113    case nir_op_fmul:
   10114       return evaluate_fmul(num_components, bit_width, src);
   10115    case nir_op_fne:
   10116       return evaluate_fne(num_components, bit_width, src);
   10117    case nir_op_fneg:
   10118       return evaluate_fneg(num_components, bit_width, src);
   10119    case nir_op_fnoise1_1:
   10120       return evaluate_fnoise1_1(num_components, bit_width, src);
   10121    case nir_op_fnoise1_2:
   10122       return evaluate_fnoise1_2(num_components, bit_width, src);
   10123    case nir_op_fnoise1_3:
   10124       return evaluate_fnoise1_3(num_components, bit_width, src);
   10125    case nir_op_fnoise1_4:
   10126       return evaluate_fnoise1_4(num_components, bit_width, src);
   10127    case nir_op_fnoise2_1:
   10128       return evaluate_fnoise2_1(num_components, bit_width, src);
   10129    case nir_op_fnoise2_2:
   10130       return evaluate_fnoise2_2(num_components, bit_width, src);
   10131    case nir_op_fnoise2_3:
   10132       return evaluate_fnoise2_3(num_components, bit_width, src);
   10133    case nir_op_fnoise2_4:
   10134       return evaluate_fnoise2_4(num_components, bit_width, src);
   10135    case nir_op_fnoise3_1:
   10136       return evaluate_fnoise3_1(num_components, bit_width, src);
   10137    case nir_op_fnoise3_2:
   10138       return evaluate_fnoise3_2(num_components, bit_width, src);
   10139    case nir_op_fnoise3_3:
   10140       return evaluate_fnoise3_3(num_components, bit_width, src);
   10141    case nir_op_fnoise3_4:
   10142       return evaluate_fnoise3_4(num_components, bit_width, src);
   10143    case nir_op_fnoise4_1:
   10144       return evaluate_fnoise4_1(num_components, bit_width, src);
   10145    case nir_op_fnoise4_2:
   10146       return evaluate_fnoise4_2(num_components, bit_width, src);
   10147    case nir_op_fnoise4_3:
   10148       return evaluate_fnoise4_3(num_components, bit_width, src);
   10149    case nir_op_fnoise4_4:
   10150       return evaluate_fnoise4_4(num_components, bit_width, src);
   10151    case nir_op_fnot:
   10152       return evaluate_fnot(num_components, bit_width, src);
   10153    case nir_op_for:
   10154       return evaluate_for(num_components, bit_width, src);
   10155    case nir_op_fpow:
   10156       return evaluate_fpow(num_components, bit_width, src);
   10157    case nir_op_fquantize2f16:
   10158       return evaluate_fquantize2f16(num_components, bit_width, src);
   10159    case nir_op_frcp:
   10160       return evaluate_frcp(num_components, bit_width, src);
   10161    case nir_op_frem:
   10162       return evaluate_frem(num_components, bit_width, src);
   10163    case nir_op_fround_even:
   10164       return evaluate_fround_even(num_components, bit_width, src);
   10165    case nir_op_frsq:
   10166       return evaluate_frsq(num_components, bit_width, src);
   10167    case nir_op_fsat:
   10168       return evaluate_fsat(num_components, bit_width, src);
   10169    case nir_op_fsign:
   10170       return evaluate_fsign(num_components, bit_width, src);
   10171    case nir_op_fsin:
   10172       return evaluate_fsin(num_components, bit_width, src);
   10173    case nir_op_fsqrt:
   10174       return evaluate_fsqrt(num_components, bit_width, src);
   10175    case nir_op_fsub:
   10176       return evaluate_fsub(num_components, bit_width, src);
   10177    case nir_op_ftrunc:
   10178       return evaluate_ftrunc(num_components, bit_width, src);
   10179    case nir_op_fxor:
   10180       return evaluate_fxor(num_components, bit_width, src);
   10181    case nir_op_i2b:
   10182       return evaluate_i2b(num_components, bit_width, src);
   10183    case nir_op_i2d:
   10184       return evaluate_i2d(num_components, bit_width, src);
   10185    case nir_op_i2f:
   10186       return evaluate_i2f(num_components, bit_width, src);
   10187    case nir_op_iabs:
   10188       return evaluate_iabs(num_components, bit_width, src);
   10189    case nir_op_iadd:
   10190       return evaluate_iadd(num_components, bit_width, src);
   10191    case nir_op_iand:
   10192       return evaluate_iand(num_components, bit_width, src);
   10193    case nir_op_ibfe:
   10194       return evaluate_ibfe(num_components, bit_width, src);
   10195    case nir_op_ibitfield_extract:
   10196       return evaluate_ibitfield_extract(num_components, bit_width, src);
   10197    case nir_op_idiv:
   10198       return evaluate_idiv(num_components, bit_width, src);
   10199    case nir_op_ieq:
   10200       return evaluate_ieq(num_components, bit_width, src);
   10201    case nir_op_ifind_msb:
   10202       return evaluate_ifind_msb(num_components, bit_width, src);
   10203    case nir_op_ige:
   10204       return evaluate_ige(num_components, bit_width, src);
   10205    case nir_op_ilt:
   10206       return evaluate_ilt(num_components, bit_width, src);
   10207    case nir_op_imax:
   10208       return evaluate_imax(num_components, bit_width, src);
   10209    case nir_op_imin:
   10210       return evaluate_imin(num_components, bit_width, src);
   10211    case nir_op_imod:
   10212       return evaluate_imod(num_components, bit_width, src);
   10213    case nir_op_imov:
   10214       return evaluate_imov(num_components, bit_width, src);
   10215    case nir_op_imul:
   10216       return evaluate_imul(num_components, bit_width, src);
   10217    case nir_op_imul_high:
   10218       return evaluate_imul_high(num_components, bit_width, src);
   10219    case nir_op_ine:
   10220       return evaluate_ine(num_components, bit_width, src);
   10221    case nir_op_ineg:
   10222       return evaluate_ineg(num_components, bit_width, src);
   10223    case nir_op_inot:
   10224       return evaluate_inot(num_components, bit_width, src);
   10225    case nir_op_ior:
   10226       return evaluate_ior(num_components, bit_width, src);
   10227    case nir_op_irem:
   10228       return evaluate_irem(num_components, bit_width, src);
   10229    case nir_op_ishl:
   10230       return evaluate_ishl(num_components, bit_width, src);
   10231    case nir_op_ishr:
   10232       return evaluate_ishr(num_components, bit_width, src);
   10233    case nir_op_isign:
   10234       return evaluate_isign(num_components, bit_width, src);
   10235    case nir_op_isub:
   10236       return evaluate_isub(num_components, bit_width, src);
   10237    case nir_op_ixor:
   10238       return evaluate_ixor(num_components, bit_width, src);
   10239    case nir_op_ldexp:
   10240       return evaluate_ldexp(num_components, bit_width, src);
   10241    case nir_op_pack_double_2x32:
   10242       return evaluate_pack_double_2x32(num_components, bit_width, src);
   10243    case nir_op_pack_double_2x32_split:
   10244       return evaluate_pack_double_2x32_split(num_components, bit_width, src);
   10245    case nir_op_pack_half_2x16:
   10246       return evaluate_pack_half_2x16(num_components, bit_width, src);
   10247    case nir_op_pack_half_2x16_split:
   10248       return evaluate_pack_half_2x16_split(num_components, bit_width, src);
   10249    case nir_op_pack_snorm_2x16:
   10250       return evaluate_pack_snorm_2x16(num_components, bit_width, src);
   10251    case nir_op_pack_snorm_4x8:
   10252       return evaluate_pack_snorm_4x8(num_components, bit_width, src);
   10253    case nir_op_pack_unorm_2x16:
   10254       return evaluate_pack_unorm_2x16(num_components, bit_width, src);
   10255    case nir_op_pack_unorm_4x8:
   10256       return evaluate_pack_unorm_4x8(num_components, bit_width, src);
   10257    case nir_op_pack_uvec2_to_uint:
   10258       return evaluate_pack_uvec2_to_uint(num_components, bit_width, src);
   10259    case nir_op_pack_uvec4_to_uint:
   10260       return evaluate_pack_uvec4_to_uint(num_components, bit_width, src);
   10261    case nir_op_seq:
   10262       return evaluate_seq(num_components, bit_width, src);
   10263    case nir_op_sge:
   10264       return evaluate_sge(num_components, bit_width, src);
   10265    case nir_op_slt:
   10266       return evaluate_slt(num_components, bit_width, src);
   10267    case nir_op_sne:
   10268       return evaluate_sne(num_components, bit_width, src);
   10269    case nir_op_u2d:
   10270       return evaluate_u2d(num_components, bit_width, src);
   10271    case nir_op_u2f:
   10272       return evaluate_u2f(num_components, bit_width, src);
   10273    case nir_op_uadd_carry:
   10274       return evaluate_uadd_carry(num_components, bit_width, src);
   10275    case nir_op_ubfe:
   10276       return evaluate_ubfe(num_components, bit_width, src);
   10277    case nir_op_ubitfield_extract:
   10278       return evaluate_ubitfield_extract(num_components, bit_width, src);
   10279    case nir_op_udiv:
   10280       return evaluate_udiv(num_components, bit_width, src);
   10281    case nir_op_ufind_msb:
   10282       return evaluate_ufind_msb(num_components, bit_width, src);
   10283    case nir_op_uge:
   10284       return evaluate_uge(num_components, bit_width, src);
   10285    case nir_op_ult:
   10286       return evaluate_ult(num_components, bit_width, src);
   10287    case nir_op_umax:
   10288       return evaluate_umax(num_components, bit_width, src);
   10289    case nir_op_umax_4x8:
   10290       return evaluate_umax_4x8(num_components, bit_width, src);
   10291    case nir_op_umin:
   10292       return evaluate_umin(num_components, bit_width, src);
   10293    case nir_op_umin_4x8:
   10294       return evaluate_umin_4x8(num_components, bit_width, src);
   10295    case nir_op_umod:
   10296       return evaluate_umod(num_components, bit_width, src);
   10297    case nir_op_umul_high:
   10298       return evaluate_umul_high(num_components, bit_width, src);
   10299    case nir_op_umul_unorm_4x8:
   10300       return evaluate_umul_unorm_4x8(num_components, bit_width, src);
   10301    case nir_op_unpack_double_2x32:
   10302       return evaluate_unpack_double_2x32(num_components, bit_width, src);
   10303    case nir_op_unpack_double_2x32_split_x:
   10304       return evaluate_unpack_double_2x32_split_x(num_components, bit_width, src);
   10305    case nir_op_unpack_double_2x32_split_y:
   10306       return evaluate_unpack_double_2x32_split_y(num_components, bit_width, src);
   10307    case nir_op_unpack_half_2x16:
   10308       return evaluate_unpack_half_2x16(num_components, bit_width, src);
   10309    case nir_op_unpack_half_2x16_split_x:
   10310       return evaluate_unpack_half_2x16_split_x(num_components, bit_width, src);
   10311    case nir_op_unpack_half_2x16_split_y:
   10312       return evaluate_unpack_half_2x16_split_y(num_components, bit_width, src);
   10313    case nir_op_unpack_snorm_2x16:
   10314       return evaluate_unpack_snorm_2x16(num_components, bit_width, src);
   10315    case nir_op_unpack_snorm_4x8:
   10316       return evaluate_unpack_snorm_4x8(num_components, bit_width, src);
   10317    case nir_op_unpack_unorm_2x16:
   10318       return evaluate_unpack_unorm_2x16(num_components, bit_width, src);
   10319    case nir_op_unpack_unorm_4x8:
   10320       return evaluate_unpack_unorm_4x8(num_components, bit_width, src);
   10321    case nir_op_usadd_4x8:
   10322       return evaluate_usadd_4x8(num_components, bit_width, src);
   10323    case nir_op_ushr:
   10324       return evaluate_ushr(num_components, bit_width, src);
   10325    case nir_op_ussub_4x8:
   10326       return evaluate_ussub_4x8(num_components, bit_width, src);
   10327    case nir_op_usub_borrow:
   10328       return evaluate_usub_borrow(num_components, bit_width, src);
   10329    case nir_op_vec2:
   10330       return evaluate_vec2(num_components, bit_width, src);
   10331    case nir_op_vec3:
   10332       return evaluate_vec3(num_components, bit_width, src);
   10333    case nir_op_vec4:
   10334       return evaluate_vec4(num_components, bit_width, src);
   10335    default:
   10336       unreachable("shouldn't get here");
   10337    }
   10338 }
   10339