-
-#if 0
- ir_value *v = instr->phi[p].value;
- for (w = 0; w < vec_size(v->writes); ++w) {
- ir_value *old;
-
- if (!v->writes[w]->_ops[0])
- continue;
-
- /* When the write was to a global, we have to emit a mov */
- old = v->writes[w]->_ops[0];
-
- /* The original instruction now writes to the PHI target local */
- if (v->writes[w]->_ops[0] == v)
- v->writes[w]->_ops[0] = instr->_ops[0];
-
- if (old->store != store_value && old->store != store_local && old->store != store_param)
- {
- /* If it originally wrote to a global we need to store the value
- * there as welli
- */
- if (!ir_naive_phi_emit_store(self, i+1, old, v))
- return false;
- if (i+1 < vec_size(self->instr))
- instr = self->instr[i+1];
- else
- instr = NULL;
- /* In case I forget and access instr later, it'll be NULL
- * when it's a problem, to make sure we crash, rather than accessing
- * invalid data.
- */
- }
- else
- {
- /* If it didn't, we can replace all reads by the phi target now. */
- size_t r;
- for (r = 0; r < vec_size(old->reads); ++r)
- {
- size_t op;
- ir_instr *ri = old->reads[r];
- for (op = 0; op < vec_size(ri->phi); ++op) {
- if (ri->phi[op].value == old)
- ri->phi[op].value = v;
- }
- for (op = 0; op < 3; ++op) {
- if (ri->_ops[op] == old)
- ri->_ops[op] = v;
- }
- }
- }
- }
-#endif