]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
What was I thinking... fixing loop's jump creation so it doesn't try creating multipl...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 4 May 2012 10:24:44 +0000 (12:24 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 4 May 2012 10:24:44 +0000 (12:24 +0200)
ast.c

diff --git a/ast.c b/ast.c
index ce89fc905283d54f7e95f2cca21349034c9c1859..be696713daa665d6dfb8ccc9d56987cf4ecdac52 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -949,6 +949,8 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
     ir_block *old_bcontinue;
     ir_block *old_bbreak;
 
+    ir_block *btemp;
+
     (void)lvalue;
     (void)out;
 
@@ -1081,14 +1083,13 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
 
     /* Now all blocks are in place */
     /* From 'bin' we jump to whatever comes first */
-    if (bprecond       && !ir_block_create_jump(bin, bprecond))
-        return false;
-    else if (bbody     && !ir_block_create_jump(bin, bbody))
-        return false;
-    else if (bpostcond && !ir_block_create_jump(bin, bpostcond))
-        return false;
-    else if (             !ir_block_create_jump(bin, bout))
+    if      (bprecond)   tmpblock = bprecond;
+    else if (bbody)      tmpblock = bbody;
+    else if (bpostcond)  tmpblock = bpostcond;
+    else                 tmpblock = bout;
+    if (!ir_block_create_jump(bin, tmpblock))
         return false;
+    }
 
     /* From precond */
     if (bprecond)
@@ -1106,27 +1107,25 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
     /* from body */
     if (bbody)
     {
-        if (bincrement     && !ir_block_create_jump(end_bbody, bincrement))
-            return false;
-        else if (bpostcond && !ir_block_create_jump(end_bbody, bpostcond))
-            return false;
-        else if (bprecond  && !ir_block_create_jump(end_bbody, bprecond))
-            return false;
-        else if              (!ir_block_create_jump(end_bbody, bout))
+        if      (bincrement) tmpblock = bincrement;
+        else if (bpostcond)  tmpblock = bpostcond;
+        else if (bprecond)   tmpblock = bprecond;
+        else                 tmpblock = bout;
+        if (!ir_block_create_jump(end_bbody, tmpblock))
             return false;
+        }
     }
 
     /* from increment */
     if (bincrement)
     {
-        if (bpostcond      && !ir_block_create_jump(end_bincrement, bpostcond))
-            return false;
-        else if (bprecond  && !ir_block_create_jump(end_bincrement, bprecond))
-            return false;
-        else if (bbody     && !ir_block_create_jump(end_bincrement, bbody))
-            return false;
-        else if              (!ir_block_create_jump(end_bincrement, bout))
+        if      (bpostcond)  tmpblock = bpostcond;
+        else if (bprecond)   tmpblock = bprecond;
+        else if (bbody)      tmpblock = bbody;
+        else                 tmpblock = bout;
+        if (!ir_block_create_jump(end_bincrement, tmpblock))
             return false;
+        }
     }
 
     /* from postcond */