From e78177db2edc5ba7e562997f4e4a86dd74d797c0 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 6 May 2026 21:48:52 -0700 Subject: [PATCH] nir/opt_constant_folding: Don't fight with nir_lower_bit_size Intel uses nir_lower_bit_size to convert 8-bit integer values to 16-bit for most instructions. By constant folding u2u8 or i2i8 through a bcsel, this lowering is undone. Fixes assertion failure in fossils/parallel-rdp/small_subgroup.foz. fossilize-replay: src/intel/compiler/brw/brw_from_nir.cpp:852: void brw_from_nir_emit_alu(nir_to_brw_state&, nir_alu_instr*, bool): Assertion `brw_type_size_bytes(op[i].type) > 1' failed. Fixes: f4812dc11d4 ("nir/opt_constant_folding: constant-fold op(bcsel(), #c) -> bcsel(.., #c1, #c2)") --- src/compiler/nir/nir_opt_constant_folding.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/nir/nir_opt_constant_folding.c b/src/compiler/nir/nir_opt_constant_folding.c index 8526e175ce9..1884cf8ddbe 100644 --- a/src/compiler/nir/nir_opt_constant_folding.c +++ b/src/compiler/nir/nir_opt_constant_folding.c @@ -75,6 +75,10 @@ should_fold_bcsel(nir_alu_instr *alu) if (alu->def.bit_size > 32) return false; + /* Don't fight with nir_lower_bit_size. */ + if (alu->op == nir_op_u2u8 || alu->op == nir_op_i2i8) + return false; + /* Don't fight with nir_lower_load_const_to_scalar. */ if (nir_op_is_vec_or_mov(alu->op)) return false;