]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
A hopefully working naive PHI solution
authorWolfgang (Blub) Bumiller <blub@speed.at>
Wed, 21 Nov 2012 15:05:54 +0000 (16:05 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Wed, 21 Nov 2012 15:05:54 +0000 (16:05 +0100)
ir.c

diff --git a/ir.c b/ir.c
index 51d03dac660dbd76205ed6990f34faf2c0b5deef..cab06582870363241c99c782266647a05db784d0 100644 (file)
--- 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);
     }