From 6d3425653a29b40f5527c7fcce9c8a9c72a88164 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 24 Aug 2023 07:08:34 -0400 Subject: [PATCH] nir/opt_gcm: Use nir_op_is_derivative more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Alyssa Rosenzweig Reviewed-by: Daniel Schürmann Part-of: --- src/compiler/nir/nir_opt_gcm.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c index 0b1e7825146..a6509b278c9 100644 --- a/src/compiler/nir/nir_opt_gcm.c +++ b/src/compiler/nir/nir_opt_gcm.c @@ -311,30 +311,20 @@ gcm_pin_instructions(nir_function_impl *impl, struct gcm_state *state) instr->index = state->num_instrs++; switch (instr->type) { - case nir_instr_type_alu: - switch (nir_instr_as_alu(instr)->op) { - case nir_op_fddx: - case nir_op_fddy: - case nir_op_fddx_fine: - case nir_op_fddy_fine: - case nir_op_fddx_coarse: - case nir_op_fddy_coarse: + case nir_instr_type_alu: { + nir_alu_instr *alu = nir_instr_as_alu(instr); + + if (nir_op_is_derivative(alu->op)) { /* These can only go in uniform control flow */ instr->pass_flags = GCM_INSTR_SCHEDULE_EARLIER_ONLY; - break; - - case nir_op_mov: - if (!is_src_scalarizable(&(nir_instr_as_alu(instr)->src[0].src))) { - instr->pass_flags = GCM_INSTR_PINNED; - break; - } - FALLTHROUGH; - - default: + } else if (alu->op == nir_op_mov && + !is_src_scalarizable(&alu->src[0].src)) { + instr->pass_flags = GCM_INSTR_PINNED; + } else { instr->pass_flags = 0; - break; } break; + } case nir_instr_type_tex: { nir_tex_instr *tex = nir_instr_as_tex(instr);