From aeb8af114153cd4c328e2a0894e6fa166ebb4e4d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 13 Feb 2023 17:30:16 -0800 Subject: [PATCH] nir/loop_analyze: Track induction variable basis information Reviewed-by: Timothy Arceri Part-of: --- src/compiler/nir/nir_loop_analyze.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/compiler/nir/nir_loop_analyze.c b/src/compiler/nir/nir_loop_analyze.c index 068078f..d998ec6 100644 --- a/src/compiler/nir/nir_loop_analyze.c +++ b/src/compiler/nir/nir_loop_analyze.c @@ -54,6 +54,16 @@ typedef struct { /* Could be a basic_induction if following uniforms are inlined */ nir_src *init_src; nir_alu_src *update_src; + + /** + * SSA def of the phi-node associated with this induction variable. + * + * Every loop induction variable has an associated phi node in the loop + * header. This may point to the same SSA def as \c def. If, however, \c def + * is the increment of the induction variable, this will point to the SSA + * def being incremented. + */ + nir_ssa_def *basis; } nir_loop_variable; typedef struct { @@ -472,13 +482,17 @@ compute_induction_information(loop_info_state *state) is_only_uniform_src(var->init_src)) { alu_src_var->init_src = var->init_src; alu_src_var->update_src = var->update_src; + alu_src_var->basis = var->def; alu_src_var->type = basic_induction; + + var->basis = var->def; var->type = basic_induction; num_induction_vars += 2; } else { var->init_src = NULL; var->update_src = NULL; + var->basis = NULL; } } -- 2.7.4