From edccd06a0b62a1a1e112be55263467e70e4e95ff Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 4 Mar 2026 10:11:28 -0500 Subject: [PATCH] nir/lower_subgroups: fix boolean clustered reductions It is legal to have a cluster size larger than the subgroup/ballot size, but our lowering would blow up in this case due to the nir_ishl_imm overflowing in the lowering. Fortunately, this is easy to handle. Fixes sub_group_clustered_reduce_logical_and() Signed-off-by: Alyssa Rosenzweig Reviewed-by: Karol Herbst Reviewed-by: Georg Lehmann Part-of: --- src/compiler/nir/nir_lower_subgroups.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir_lower_subgroups.c b/src/compiler/nir/nir_lower_subgroups.c index 1e1c52b704d..67cbf56f854 100644 --- a/src/compiler/nir/nir_lower_subgroups.c +++ b/src/compiler/nir/nir_lower_subgroups.c @@ -645,10 +645,12 @@ lower_boolean_reduce(nir_builder *b, nir_intrinsic_instr *intrin, nir_op op = nir_intrinsic_reduction_op(intrin); /* For certain cluster sizes, reductions of iand and ior can be implemented - * more efficiently. + * more efficiently. This also avoids a special case in + * lower_boolean_reduce_internal. */ if (intrin->intrinsic == nir_intrinsic_reduce) { - if (cluster_size == 0) { + if (cluster_size == 0 || cluster_size >= options->ballot_components * + options->ballot_bit_size) { if (op == nir_op_iand) return nir_vote_all(b, 1, intrin->src[0].ssa); else if (op == nir_op_ior)