From: Wolfgang (Blub) Bumiller Date: Wed, 21 Nov 2012 15:05:54 +0000 (+0100) Subject: A hopefully working naive PHI solution X-Git-Tag: 0.1.9~384 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=390ac0d871f65a169fe7d30d82fe7e69bf9c90d4;p=xonotic%2Fgmqcc.git A hopefully working naive PHI solution --- diff --git a/ir.c b/ir.c index 51d03da..cab0658 100644 --- a/ir.c +++ b/ir.c @@ -1804,6 +1804,31 @@ static bool ir_block_naive_phi(ir_block *self) for (p = 0; p < vec_size(instr->phi); ++p) { + ir_value *v = instr->phi[p].value; + ir_block *b = instr->phi[p].from; + + if (v->store == store_value && + vec_size(v->reads) == 1 && + vec_size(v->writes) == 1) + { + /* replace the value */ + ir_instr_op(v->writes[0], 0, instr->_ops[0], true); + } + else + { + /* force a move instruction */ + ir_instr *prevjump = vec_last(b->instr); + vec_pop(b->instr); + b->final = false; + instr->_ops[0]->store = store_global; + if (!ir_block_create_store(b, instr->_ops[0], v)) + return false; + instr->_ops[0]->store = store_value; + vec_push(b->instr, prevjump); + b->final = true; + } + +#if 0 ir_value *v = instr->phi[p].value; for (w = 0; w < vec_size(v->writes); ++w) { ir_value *old; @@ -1853,6 +1878,7 @@ static bool ir_block_naive_phi(ir_block *self) } } } +#endif } ir_instr_delete(instr); }