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.
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++)