Skip to content

Commit

Permalink
nir: Support deref instructions in opt_undef
Browse files Browse the repository at this point in the history
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>

v2: Use correct src index for store_deref (Bas)
  • Loading branch information
gfxstrand authored and BNieuwenhuizen committed Jun 1, 2018
1 parent df3a0c4 commit e967c87
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/compiler/nir/nir_opt_undef.c
Expand Up @@ -107,19 +107,24 @@ opt_undef_vecN(nir_builder *b, nir_alu_instr *alu)
static bool
opt_undef_store(nir_intrinsic_instr *intrin)
{
unsigned src_index = 0;
switch (intrin->intrinsic) {
case nir_intrinsic_store_deref:
src_index = 1;
break;
case nir_intrinsic_store_var:
case nir_intrinsic_store_output:
case nir_intrinsic_store_per_vertex_output:
case nir_intrinsic_store_ssbo:
case nir_intrinsic_store_shared:
src_index = 0;
break;
default:
return false;
}

if (!intrin->src[0].is_ssa ||
intrin->src[0].ssa->parent_instr->type != nir_instr_type_ssa_undef)
if (!intrin->src[src_index].is_ssa ||
intrin->src[src_index].ssa->parent_instr->type != nir_instr_type_ssa_undef)
return false;

nir_instr_remove(&intrin->instr);
Expand All @@ -133,8 +138,6 @@ nir_opt_undef(nir_shader *shader)
nir_builder b;
bool progress = false;

nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);

nir_foreach_function(function, shader) {
if (function->impl) {
nir_builder_init(&b, function->impl);
Expand Down

0 comments on commit e967c87

Please sign in to comment.