From 7bab441ae6a60e33a804dc918a16578c65605833 Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Fri, 29 Nov 2024 17:09:15 +0100 Subject: [PATCH] ir3: remove unused ir3_nir_lower_64b_subgroups Signed-off-by: Job Noorman Part-of: --- src/freedreno/ir3/ir3_lower_subgroups.c | 104 ------------------------ src/freedreno/ir3/ir3_nir.h | 1 - 2 files changed, 105 deletions(-) diff --git a/src/freedreno/ir3/ir3_lower_subgroups.c b/src/freedreno/ir3/ir3_lower_subgroups.c index fea9eb3be18..1979752e6bb 100644 --- a/src/freedreno/ir3/ir3_lower_subgroups.c +++ b/src/freedreno/ir3/ir3_lower_subgroups.c @@ -621,110 +621,6 @@ ir3_nir_lower_subgroups_filter(const nir_instr *instr, const void *data) } } -static bool -filter_64b_scan_reduce(const nir_instr *instr, const void *data) -{ - if (instr->type != nir_instr_type_intrinsic) - return false; - - nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); - - switch (intrin->intrinsic) { - case nir_intrinsic_reduce: - case nir_intrinsic_inclusive_scan: - case nir_intrinsic_exclusive_scan: - switch (nir_intrinsic_reduction_op(intrin)) { - case nir_op_imul: - case nir_op_imin: - case nir_op_imax: - case nir_op_umin: - case nir_op_umax: - return intrin->def.bit_size == 64; - default: - /* Will be handled by nir_lower_int64. */ - return false; - } - default: - return false; - } -} - -/* The existing scan/reduce macros (OPC_SCAN_MACRO/OPC_SCAN_CLUSTERS_MACRO) hard - * code the reduction operations in ir3. Adding support for 64b operations will - * blow up these already complicated macros. Implement a simple scan loop in NIR - * for the few (hopefully rare) cases where the generic passes cannot lower the - * reduction to 32b. - * - * inclusive = exclusive = ident; - * while (true) { - * exclusive = inclusive; - * inclusive = inclusive OP subgroupBroadcastFirst(inclusive_in); - * if (elect()) { - * break; - * } - * } - * reduce = subgroupBroadcast(inclusive, - * subgroupBallotFindMSB(subgroupBallot(true))); - */ -static nir_def * -lower_64b_scan_reduce(struct nir_builder *b, nir_instr *instr, void *data) -{ - nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); - assert(intrin->def.num_components == 1); - - unsigned bit_size = intrin->def.bit_size; - nir_op op = nir_intrinsic_reduction_op(intrin); - - nir_const_value ident_val = nir_alu_binop_identity(op, bit_size); - nir_def *ident = nir_build_imm(b, 1, bit_size, &ident_val); - nir_def *inclusive_in = intrin->src[0].ssa; - - const glsl_type *var_type = glsl_type_for_def(inclusive_in); - nir_variable *inclusive_var = - nir_local_variable_create(b->impl, var_type, "inclusive"); - nir_variable *exclusive_var = - nir_local_variable_create(b->impl, var_type, "exclusive"); - nir_store_var(b, inclusive_var, ident, 1); - nir_store_var(b, exclusive_var, ident, 1); - - nir_loop *loop = nir_push_loop(b); - { - nir_def *inclusive = nir_load_var(b, inclusive_var); - nir_store_var(b, exclusive_var, inclusive, 1); - - nir_def *inclusive_in_next = nir_read_first_invocation(b, inclusive_in); - nir_def *inclusive_next = - nir_build_alu2(b, op, inclusive, inclusive_in_next); - nir_store_var(b, inclusive_var, inclusive_next, 1); - - nir_break_if(b, nir_elect(b, 1)); - } - nir_pop_loop(b, loop); - - switch (intrin->intrinsic) { - case nir_intrinsic_reduce: { - nir_def *active_invocations = nir_ballot(b, 4, 32, nir_imm_true(b)); - nir_def *last_active_invocation = - nir_ballot_find_msb(b, 32, active_invocations); - return nir_read_invocation(b, nir_load_var(b, inclusive_var), - last_active_invocation); - } - case nir_intrinsic_inclusive_scan: - return nir_load_var(b, inclusive_var); - case nir_intrinsic_exclusive_scan: - return nir_load_var(b, exclusive_var); - default: - unreachable("filtered intrinsic"); - } -} - -bool -ir3_nir_lower_64b_subgroups(nir_shader *nir) -{ - return nir_shader_lower_instructions(nir, filter_64b_scan_reduce, - lower_64b_scan_reduce, NULL); -} - static bool filter_shuffle(const nir_instr *instr, const void *data) { diff --git a/src/freedreno/ir3/ir3_nir.h b/src/freedreno/ir3/ir3_nir.h index 4bf947399bf..7aabc5de438 100644 --- a/src/freedreno/ir3/ir3_nir.h +++ b/src/freedreno/ir3/ir3_nir.h @@ -92,7 +92,6 @@ nir_def *ir3_nir_try_propagate_bit_shift(nir_builder *b, int32_t shift); bool ir3_nir_lower_subgroups_filter(const nir_instr *instr, const void *data); -bool ir3_nir_lower_64b_subgroups(nir_shader *nir); bool ir3_nir_lower_shuffle(nir_shader *nir, struct ir3_shader *shader); bool ir3_nir_opt_subgroups(nir_shader *nir, struct ir3_shader_variant *v);