diff options
author | Jason Ekstrand <[email protected]> | 2018-03-17 11:22:03 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-06-22 20:15:55 -0700 |
commit | 1442969ae1a3c5d75fbfa02f9e293a43706b7f7d (patch) | |
tree | 945c530580f2722c005ca9713056d2b1c16c5b0b /src/compiler/nir/nir_propagate_invariant.c | |
parent | f23356a4dda11dc5e22a48d5a8df7a6fd8ab4634 (diff) |
nir: Support deref instructions in propagate_invariant
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Acked-by: Rob Clark <[email protected]>
Acked-by: Bas Nieuwenhuizen <[email protected]>
Acked-by: Dave Airlie <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_propagate_invariant.c')
-rw-r--r-- | src/compiler/nir/nir_propagate_invariant.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/compiler/nir/nir_propagate_invariant.c b/src/compiler/nir/nir_propagate_invariant.c index d8dc6a03689..63340c4ab68 100644 --- a/src/compiler/nir/nir_propagate_invariant.c +++ b/src/compiler/nir/nir_propagate_invariant.c @@ -74,6 +74,15 @@ var_is_invariant(nir_variable *var, struct set * invariants) return var->data.invariant || _mesa_set_search(invariants, var); } +static nir_variable * +intrinsic_get_var(nir_intrinsic_instr *intrin, unsigned i) +{ + if (nir_intrinsic_infos[intrin->intrinsic].num_variables == 0) + return nir_deref_instr_get_variable(nir_src_as_deref(intrin->src[i])); + else + return intrin->variables[i]->var; +} + static void propagate_invariant_instr(nir_instr *instr, struct set *invariants) { @@ -99,14 +108,16 @@ propagate_invariant_instr(nir_instr *instr, struct set *invariants) nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); switch (intrin->intrinsic) { case nir_intrinsic_copy_var: + case nir_intrinsic_copy_deref: /* If the destination is invariant then so is the source */ - if (var_is_invariant(intrin->variables[0]->var, invariants)) - add_var(intrin->variables[1]->var, invariants); + if (var_is_invariant(intrinsic_get_var(intrin, 0), invariants)) + add_var(intrinsic_get_var(intrin, 1), invariants); break; case nir_intrinsic_load_var: + case nir_intrinsic_load_deref: if (dest_is_invariant(&intrin->dest, invariants)) - add_var(intrin->variables[0]->var, invariants); + add_var(intrinsic_get_var(intrin, 0), invariants); break; case nir_intrinsic_store_var: @@ -114,12 +125,18 @@ propagate_invariant_instr(nir_instr *instr, struct set *invariants) add_src(&intrin->src[0], invariants); break; + case nir_intrinsic_store_deref: + if (var_is_invariant(intrinsic_get_var(intrin, 0), invariants)) + add_src(&intrin->src[1], invariants); + break; + default: /* Nothing to do */ break; } } + case nir_instr_type_deref: case nir_instr_type_jump: case nir_instr_type_ssa_undef: case nir_instr_type_load_const: @@ -184,8 +201,6 @@ nir_propagate_invariant(nir_shader *shader) struct set *invariants = _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal); - nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs); - bool progress = false; nir_foreach_function(function, shader) { if (function->impl && propagate_invariant_impl(function->impl, invariants)) |