From 462ef200d81d12d6ff0876b5cfc2a17783f930d1 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 18 May 2023 17:15:04 -0700 Subject: [PATCH] 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 Reviewed-by: Karol Herbst Reviewed-by: Faith Ekstrand Part-of: --- src/compiler/nir/nir_lower_bit_size.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/nir/nir_lower_bit_size.c b/src/compiler/nir/nir_lower_bit_size.c index 2b221bf..9d81bb3 100644 --- a/src/compiler/nir/nir_lower_bit_size.c +++ b/src/compiler/nir/nir_lower_bit_size.c @@ -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 && -- 2.7.4