From 5ae89dbf4804e48ef282f58b8ccd14f14a3c9f59 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Thu, 5 Feb 2026 23:09:00 -0500 Subject: [PATCH] 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 Part-of: --- src/panfrost/compiler/bifrost/bifrost_compile.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/panfrost/compiler/bifrost/bifrost_compile.c b/src/panfrost/compiler/bifrost/bifrost_compile.c index 60199fbf49d..c626ed21c63 100644 --- a/src/panfrost/compiler/bifrost/bifrost_compile.c +++ b/src/panfrost/compiler/bifrost/bifrost_compile.c @@ -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;