[1/2] nir/loop_analyze: use nir_src to track the invariant

Submitted by Timothy Arceri on June 19, 2019, 3:41 a.m.

Details

Message ID 20190619034108.13900-1-tarceri@itsqueeze.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Timothy Arceri June 19, 2019, 3:41 a.m.
This helps reduce the amount of abstraction in this pass and allows
us to retain more information about the src such as any swizzles.
Retaining the swizzle information is required for a bugfix in a
following patch.

Fixes: 6772a17acc8e ("nir: Add a loop analysis pass")
---
 src/compiler/nir/nir_loop_analyze.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/compiler/nir/nir_loop_analyze.c b/src/compiler/nir/nir_loop_analyze.c
index 0ae9533e007..ff73b32c51d 100644
--- a/src/compiler/nir/nir_loop_analyze.c
+++ b/src/compiler/nir/nir_loop_analyze.c
@@ -60,7 +60,7 @@  typedef struct {
 typedef struct nir_basic_induction_var {
    nir_op alu_op;                           /* The type of alu-operation    */
    nir_loop_variable *alu_def;              /* The def of the alu-operation */
-   nir_loop_variable *invariant;            /* The invariant alu-operand    */
+   nir_alu_src *invariant;                  /* The invariant alu-src        */
    nir_loop_variable *def_outside_loop;     /* The phi-src outside the loop */
 } nir_basic_induction_var;
 
@@ -356,7 +356,7 @@  compute_induction_information(loop_info_state *state)
                   /* Is one of the operands const, and the other the phi */
                   if (alu->src[i].src.ssa->parent_instr->type == nir_instr_type_load_const &&
                       alu->src[1-i].src.ssa == &phi->dest.ssa)
-                     biv->invariant = get_loop_var(alu->src[i].src.ssa, state);
+                     biv->invariant = &alu->src[i];
                }
             }
          }
@@ -364,7 +364,7 @@  compute_induction_information(loop_info_state *state)
 
       if (biv->alu_def && biv->def_outside_loop && biv->invariant &&
           is_var_constant(biv->def_outside_loop)) {
-         assert(is_var_constant(biv->invariant));
+         assert(is_var_constant(get_loop_var(biv->invariant->src.ssa, state)));
          biv->alu_def->type = basic_induction;
          biv->alu_def->ind = biv;
          var->type = basic_induction;
@@ -960,8 +960,8 @@  find_trip_count(loop_info_state *state)
                                     def->parent_instr)->value;
 
       nir_const_value *step_val =
-         nir_instr_as_load_const(basic_ind->ind->invariant->def->
-                                    parent_instr)->value;
+         nir_instr_as_load_const(basic_ind->ind->invariant->src.ssa->
+                                 parent_instr)->value;
 
       int iterations = calculate_iterations(initial_val, step_val,
                                             &limit_val,