From 3c93ebbae58e3e3f5b1ab716a801eb9dfb26fbff Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Mon, 26 Jul 2021 17:13:52 +0800 Subject: [PATCH] nir/loop_analyze: skip unsupported induction variable early MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of fail in trip count calculation, just don't mark such kind of variable as induction from the beginning. Don't bother inline uniform to deal with such kind of variable either. Reviewed-by: Marek Olšák Signed-off-by: Qiang Yu Part-of: --- src/compiler/nir/nir_loop_analyze.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/nir/nir_loop_analyze.c b/src/compiler/nir/nir_loop_analyze.c index 551680d11f5..65291a70a9a 100644 --- a/src/compiler/nir/nir_loop_analyze.c +++ b/src/compiler/nir/nir_loop_analyze.c @@ -416,6 +416,10 @@ compute_induction_information(loop_info_state *state) alu_src_var = src_var; nir_alu_instr *alu = nir_instr_as_alu(src_var->def->parent_instr); + /* Check for unsupported alu operations */ + if (alu->op != nir_op_iadd && alu->op != nir_op_fadd) + break; + if (nir_op_infos[alu->op].num_inputs == 2) { for (unsigned i = 0; i < 2; i++) { /* Is one of the operands const or uniform, and the other the phi. @@ -857,9 +861,8 @@ calculate_iterations(nir_const_value initial, nir_const_value step, induction_base_type); } - /* Check for nsupported alu operations */ - if (alu->op != nir_op_iadd && alu->op != nir_op_fadd) - return -1; + /* Only variable with these update ops were marked as induction. */ + assert(alu->op == nir_op_iadd || alu->op == nir_op_fadd); /* do-while loops can increment the starting value before the condition is * checked. e.g.