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 <alyssa.rosenzweig@intel.com>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40224>
This commit is contained in:
Alyssa Rosenzweig 2026-03-04 10:11:28 -05:00 committed by Marge Bot
parent 97756219c4
commit edccd06a0b

View file

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