nir/builder: Handle any bit-size selector in nir_extract
authorJason Ekstrand <jason@jlekstrand.net>
Fri, 17 Apr 2020 14:52:25 +0000 (09:52 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 17 Apr 2020 19:21:44 +0000 (19:21 +0000)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4495>

src/compiler/nir/nir_builder.h

index 69c7d312b841adcc10e18969b5f9562b7fe4d3c0..481ea6382bf88c262491752fda1739bd0c464439 100644 (file)
@@ -580,7 +580,7 @@ _nir_vector_extract_helper(nir_builder *b, nir_ssa_def *vec, nir_ssa_def *c,
       return nir_channel(b, vec, start);
    } else {
       unsigned mid = start + (end - start) / 2;
-      return nir_bcsel(b, nir_ilt(b, c, nir_imm_int(b, mid)),
+      return nir_bcsel(b, nir_ilt(b, c, nir_imm_intN_t(b, mid, c->bit_size)),
                        _nir_vector_extract_helper(b, vec, c, start, mid),
                        _nir_vector_extract_helper(b, vec, c, mid, end));
    }
@@ -591,7 +591,7 @@ nir_vector_extract(nir_builder *b, nir_ssa_def *vec, nir_ssa_def *c)
 {
    nir_src c_src = nir_src_for_ssa(c);
    if (nir_src_is_const(c_src)) {
-      unsigned c_const = nir_src_as_uint(c_src);
+      uint64_t c_const = nir_src_as_uint(c_src);
       if (c_const < vec->num_components)
          return nir_channel(b, vec, c_const);
       else