Module: Mesa
Branch: main
Commit: aeb8af114153cd4c328e2a0894e6fa166ebb4e4d
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=aeb8af114153cd4c328e2a0894e6fa166ebb4e4d

Author: Ian Romanick <[email protected]>
Date:   Mon Feb 13 17:30:16 2023 -0800

nir/loop_analyze: Track induction variable basis information

Reviewed-by: Timothy Arceri <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3445>

---

 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 068078fd256..d998ec6f019 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;
       }
    }
 

Reply via email to