nir/spirv: Use instr_rewrite_src for updating phi sources

You can't just add a new source to a phi because use/def information won't
get updated properly.  Instead, you have to use one of the core helpers.
Some day, we may want to add a nir_phi_instr_add_src helper.
This commit is contained in:
Jason Ekstrand
2015-12-29 15:44:37 -08:00
parent 69d5838aee
commit 2a58cb03d0

View File

@@ -3039,8 +3039,10 @@ vtn_phi_node_add_src(struct vtn_ssa_value *phi, const nir_block *pred,
nir_phi_instr *phi_instr = nir_instr_as_phi(phi->def->parent_instr);
nir_phi_src *src = ralloc(phi_instr, nir_phi_src);
src->pred = (nir_block *) pred;
src->src = nir_src_for_ssa(val->def);
src->src = NIR_SRC_INIT;
exec_list_push_tail(&phi_instr->srcs, &src->node);
nir_instr_rewrite_src(&phi_instr->instr, &src->src,
nir_src_for_ssa(val->def));
} else {
unsigned elems = glsl_get_length(phi->type);
for (unsigned i = 0; i < elems; i++)