Commit 0974914e authored by Timothy Arceri's avatar Timothy Arceri

nir/loop_analyze: use nir_alu_src to track the invariant

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: 6772a17a ("nir: Add a loop analysis pass")
Tested-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
parent 21dd8814
...@@ -60,7 +60,7 @@ typedef struct { ...@@ -60,7 +60,7 @@ typedef struct {
typedef struct nir_basic_induction_var { typedef struct nir_basic_induction_var {
nir_op alu_op; /* The type of alu-operation */ nir_op alu_op; /* The type of alu-operation */
nir_loop_variable *alu_def; /* The def of the 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_loop_variable *def_outside_loop; /* The phi-src outside the loop */
} nir_basic_induction_var; } nir_basic_induction_var;
...@@ -356,7 +356,7 @@ compute_induction_information(loop_info_state *state) ...@@ -356,7 +356,7 @@ compute_induction_information(loop_info_state *state)
/* Is one of the operands const, and the other the phi */ /* 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 && if (alu->src[i].src.ssa->parent_instr->type == nir_instr_type_load_const &&
alu->src[1-i].src.ssa == &phi->dest.ssa) 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) ...@@ -364,7 +364,7 @@ compute_induction_information(loop_info_state *state)
if (biv->alu_def && biv->def_outside_loop && biv->invariant && if (biv->alu_def && biv->def_outside_loop && biv->invariant &&
is_var_constant(biv->def_outside_loop)) { 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->type = basic_induction;
biv->alu_def->ind = biv; biv->alu_def->ind = biv;
var->type = basic_induction; var->type = basic_induction;
...@@ -960,8 +960,8 @@ find_trip_count(loop_info_state *state) ...@@ -960,8 +960,8 @@ find_trip_count(loop_info_state *state)
def->parent_instr)->value; def->parent_instr)->value;
nir_const_value *step_val = nir_const_value *step_val =
nir_instr_as_load_const(basic_ind->ind->invariant->def-> nir_instr_as_load_const(basic_ind->ind->invariant->src.ssa->
parent_instr)->value; parent_instr)->value;
int iterations = calculate_iterations(initial_val, step_val, int iterations = calculate_iterations(initial_val, step_val,
&limit_val, &limit_val,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment