nir/lower_bit_size: Use b2b for boolean subgroup ops

Without this, we replace vote_ieq(b) with vote_ieq(u2u32(b)) which is
wonky because we're doing a u2u on a 1-bit type. With this, we now
replace it with vote_ieq(b2b32(b)).  For other subgroup ops, we replace
things like *scan[op](b) with *scan[op](b2b32(b)).  For scan ops, this
assumes that b2b1(op(b1b32(x), b2b32(y))) = op(x, y) for all of the ops
iand, ior, and ixor.  This is true on all the back-ends I'm aware of.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25894>
This commit is contained in:
Faith Ekstrand
2023-10-24 13:43:07 -05:00
committed by Marge Bot
parent 5014759133
commit 49b3118302

View File

@@ -148,7 +148,9 @@ lower_intrinsic_instr(nir_builder *b, nir_intrinsic_instr *intrin,
assert(old_bit_size < bit_size); assert(old_bit_size < bit_size);
nir_alu_type type = nir_type_uint; nir_alu_type type = nir_type_uint;
if (nir_intrinsic_has_reduction_op(intrin)) if (old_bit_size == 1)
type = nir_type_bool;
else if (nir_intrinsic_has_reduction_op(intrin))
type = nir_op_infos[nir_intrinsic_reduction_op(intrin)].input_types[0]; type = nir_op_infos[nir_intrinsic_reduction_op(intrin)].input_types[0];
b->cursor = nir_before_instr(&intrin->instr); b->cursor = nir_before_instr(&intrin->instr);
@@ -205,6 +207,8 @@ lower_intrinsic_instr(nir_builder *b, nir_intrinsic_instr *intrin,
nir_alu_type type = nir_type_uint; nir_alu_type type = nir_type_uint;
if (intrin->intrinsic == nir_intrinsic_vote_feq) if (intrin->intrinsic == nir_intrinsic_vote_feq)
type = nir_type_float; type = nir_type_float;
else if (intrin->src[0].ssa->bit_size == 1)
type = nir_type_bool;
b->cursor = nir_before_instr(&intrin->instr); b->cursor = nir_before_instr(&intrin->instr);
nir_def *new_src = nir_convert_to_bit_size(b, intrin->src[0].ssa, nir_def *new_src = nir_convert_to_bit_size(b, intrin->src[0].ssa,