]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
removing a goto loop
authorWolfgang Bumiller <blub@speed.at>
Wed, 9 Jan 2013 15:00:16 +0000 (16:00 +0100)
committerWolfgang Bumiller <blub@speed.at>
Wed, 9 Jan 2013 15:00:16 +0000 (16:00 +0100)
ir.c

diff --git a/ir.c b/ir.c
index a9a28b3a1e8ffa11af1eeb307ee366e30913f4c1..5fde1bad5b466db162ee01d218112d36bb77cc5d 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -2740,7 +2740,6 @@ static bool gen_blocks_recursive(ir_function *func, ir_block *block)
     size_t    stidx;
     size_t    i;
 
-tailcall:
     block->generated = true;
     block->code_start = vec_size(code_statements);
     for (i = 0; i < vec_size(block->instr); ++i)
@@ -2757,10 +2756,8 @@ tailcall:
             /* for uncoditional jumps, if the target hasn't been generated
              * yet, we generate them right here.
              */
-            if (!target->generated) {
-                block = target;
-                goto tailcall;
-            }
+            if (!target->generated)
+                return gen_blocks_recursive(func, target);
 
             /* otherwise we generate a jump instruction */
             stmt.opcode = INSTR_GOTO;
@@ -2798,16 +2795,12 @@ tailcall:
                     code_push_statement(&stmt, instr->context.line);
             }
             if (!ontrue->generated) {
-                if (onfalse->generated) {
-                    block = ontrue;
-                    goto tailcall;
-                }
+                if (onfalse->generated)
+                    return gen_blocks_recursive(func, ontrue);
             }
             if (!onfalse->generated) {
-                if (ontrue->generated) {
-                    block = onfalse;
-                    goto tailcall;
-                }
+                if (ontrue->generated)
+                    return gen_blocks_recursive(func, onfalse);
             }
             /* neither ontrue nor onfalse exist */
             stmt.opcode = INSTR_IFNOT;
@@ -2861,8 +2854,7 @@ tailcall:
                 code_pop_statement();
             }
             /* if not, generate now */
-            block = onfalse;
-            goto tailcall;
+            return gen_blocks_recursive(func, onfalse);
         }
 
         if ( (instr->opcode >= INSTR_CALL0 && instr->opcode <= INSTR_CALL8)