pan/bi: Allow vector booleans

Lower booleans to their bit size before we lower ALU widths so the ALU
widths will use the final size of the boolean, not the bool size.  But
also, if we do have a boolean vector (the order in which these passes
get called isn't as obvious as you'd like), we want to let it stay
max-width and then lower it after we've converted it to a wide boolean.
Otherwise, we'll end up scalarizing lots of boolean stuff we don't mean
to just because it hits the else case.

Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39725>
This commit is contained in:
Faith Ekstrand 2026-02-05 23:09:00 -05:00 committed by Marge Bot
parent 6847143847
commit 5ae89dbf48

View file

@ -5590,7 +5590,9 @@ bi_vectorize_filter(const nir_instr *instr, const void *data)
const uint8_t bit_size = nir_alu_instr_is_comparison(alu)
? nir_src_bit_size(alu->src[0].src)
: alu->def.bit_size;
if (bit_size == 8)
if (bit_size == 1)
return 0;
else if (bit_size == 8)
switch (alu->op) {
case nir_op_imul:
case nir_op_i2i8:
@ -5871,9 +5873,9 @@ bi_optimize_nir(nir_shader *nir, unsigned gpu_id, nir_variable_mode robust2_mode
if (pan_arch(gpu_id) < 9)
NIR_PASS(_, nir, bifrost_nir_opt_boolean_bitwise);
NIR_PASS(_, nir, nir_lower_bool_to_bitsize);
NIR_PASS(_, nir, nir_lower_alu_width, bi_vectorize_filter, &gpu_id);
NIR_PASS(_, nir, nir_opt_vectorize, bi_vectorize_filter, &gpu_id);
NIR_PASS(_, nir, nir_lower_bool_to_bitsize);
/* Prepass to simplify instruction selection */
bool late_algebraic_progress = true;