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: f4812dc11d ("nir/opt_constant_folding: constant-fold op(bcsel(), #c) -> bcsel(.., #c1, #c2)")
This commit is contained in:
Ian Romanick 2026-05-06 21:48:52 -07:00
parent 593e3b3916
commit e78177db2e

View file

@ -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;