nir: Assert that we don't shrink bit-sizes in nir_lower_bit_size()

The idea of this pass is to promote small bit-sizes to larger, supported
bit-sizes for certain operations.  It doesn't handle emulating large
bit-size operations on smaller bit-sizes; passes like nir_lower_int64
and nir_lower_doubles handle that.

So, assert that we aren't shrinking the bit-size, as this will almost
certainly produce incorrect results.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23123>
This commit is contained in:
Kenneth Graunke 2023-05-18 17:15:04 -07:00 committed by Marge Bot
parent a2d384a5c0
commit 462ef200d8

View file

@ -33,6 +33,8 @@
static nir_ssa_def *convert_to_bit_size(nir_builder *bld, nir_ssa_def *src,
nir_alu_type type, unsigned bit_size)
{
assert(src->bit_size < bit_size);
/* create b2i32(a) instead of i2i32(b2i8(a))/i2i32(b2i16(a)) */
nir_alu_instr *alu = nir_src_as_alu_instr(nir_src_for_ssa(src));
if ((type & (nir_type_uint | nir_type_int)) && bit_size == 32 &&