summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2014-11-04 11:02:09 -0800
committerJason Ekstrand <[email protected]>2015-01-15 07:19:00 -0800
commit946012f10f93f249444436dc780ae74d477e44a3 (patch)
treeaacbd1abc60650e6d87a2b21f971761a77225802 /src/glsl
parentfbc443ad564a46e105e0b1d7a12a6f2b07c56b1d (diff)
nir: Automatically handle SSA uses when an instruction is inserted
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/nir/nir.c16
-rw-r--r--src/glsl/nir/nir_to_ssa.c16
2 files changed, 6 insertions, 26 deletions
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 5e5f1aca750..3b74e424bbe 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -1144,12 +1144,9 @@ add_use_cb(nir_src *src, void *state)
{
nir_instr *instr = (nir_instr *) state;
- if (src->is_ssa)
- return true;
-
- nir_register *reg = src->reg.reg;
+ struct set *uses_set = src->is_ssa ? src->ssa->uses : src->reg.reg->uses;
- _mesa_set_add(reg->uses, _mesa_hash_pointer(instr), instr);
+ _mesa_set_add(uses_set, _mesa_hash_pointer(instr), instr);
return true;
}
@@ -1280,16 +1277,13 @@ remove_use_cb(nir_src *src, void *state)
{
nir_instr *instr = (nir_instr *) state;
- if (src->is_ssa)
- return true;
-
- nir_register *reg = src->reg.reg;
+ struct set *uses_set = src->is_ssa ? src->ssa->uses : src->reg.reg->uses;
- struct set_entry *entry = _mesa_set_search(reg->uses,
+ struct set_entry *entry = _mesa_set_search(uses_set,
_mesa_hash_pointer(instr),
instr);
if (entry)
- _mesa_set_remove(reg->uses, entry);
+ _mesa_set_remove(uses_set, entry);
return true;
}
diff --git a/src/glsl/nir/nir_to_ssa.c b/src/glsl/nir/nir_to_ssa.c
index 26deb355e9c..fb36ff4f649 100644
--- a/src/glsl/nir/nir_to_ssa.c
+++ b/src/glsl/nir/nir_to_ssa.c
@@ -235,13 +235,8 @@ rewrite_def_forwards(nir_dest *dest, void *_state)
csel->dest.dest.reg.reg = dest->reg.reg;
csel->dest.write_mask = (1 << dest->reg.reg->num_components) - 1;
csel->src[0].src = nir_src_copy(*state->predicate, state->mem_ctx);
- if (csel->src[0].src.is_ssa)
- _mesa_set_add(csel->src[0].src.ssa->uses,
- _mesa_hash_pointer(&csel->instr), &csel->instr);
csel->src[2].src.is_ssa = true;
csel->src[2].src.ssa = get_ssa_src(dest->reg.reg, state);
- _mesa_set_add(csel->src[2].src.ssa->uses,
- _mesa_hash_pointer(&csel->instr), &csel->instr);
}
dest->is_ssa = true;
@@ -265,8 +260,6 @@ rewrite_def_forwards(nir_dest *dest, void *_state)
if (state->predicate) {
csel->src[1].src.is_ssa = true;
csel->src[1].src.ssa = &dest->ssa;
- _mesa_set_add(dest->ssa.uses, _mesa_hash_pointer(&csel->instr),
- &csel->instr);
nir_instr *old_parent_instr = state->parent_instr;
nir_src *old_predicate = state->predicate;
@@ -386,18 +379,11 @@ rewrite_alu_instr_forward(nir_alu_instr *instr, rewrite_state *state)
vec->src[i].src.ssa = old_src;
vec->src[i].swizzle[0] = i;
}
-
- _mesa_set_add(vec->src[i].src.ssa->uses,
- _mesa_hash_pointer(&vec->instr), &vec->instr);
}
vec->has_predicate = instr->has_predicate;
- if (instr->has_predicate) {
+ if (instr->has_predicate)
vec->predicate = nir_src_copy(instr->predicate, state->mem_ctx);
- if (vec->predicate.is_ssa)
- _mesa_set_add(vec->predicate.ssa->uses,
- _mesa_hash_pointer(&vec->instr), &vec->instr);
- }
nir_instr_insert_after(&instr->instr, &vec->instr);