]> de.git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.c
More jump removal
[xonotic/gmqcc.git] / ir.c
diff --git a/ir.c b/ir.c
index 6bc766c7dd7a47e0af8f2525341e488b1be2fe18..2375d55368c40d0d52c5e194f70f39a1439622b2 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -2743,8 +2743,7 @@ tailcall:
                 ontrue = tmp;
             }
             stidx = vec_size(code_statements);
-            if (stmt.o2.s1 != 1)
-                code_push_statement(&stmt, instr->context.line);
+            code_push_statement(&stmt, instr->context.line);
             /* on false we jump, so add ontrue-path */
             if (!gen_blocks_recursive(func, ontrue))
                 return false;
@@ -2754,6 +2753,12 @@ tailcall:
             if (onfalse->generated) {
                 /* fixup the jump address */
                 code_statements[stidx].o2.s1 = (onfalse->code_start) - (stidx);
+                if (code_statements[stidx].o2.s1 == 1) {
+                    code_statements[stidx] = code_statements[stidx+1];
+                    if (code_statements[stidx].o1.s1 < 0)
+                        code_statements[stidx].o1.s1++;
+                    code_pop_statement();
+                }
                 stmt.opcode = vec_last(code_statements).opcode;
                 if (stmt.opcode == INSTR_GOTO ||
                     stmt.opcode == INSTR_IF ||
@@ -2773,6 +2778,12 @@ tailcall:
                     code_push_statement(&stmt, instr->context.line);
                 return true;
             }
+            else if (code_statements[stidx].o2.s1 == 1) {
+                code_statements[stidx] = code_statements[stidx+1];
+                if (code_statements[stidx].o1.s1 < 0)
+                    code_statements[stidx].o1.s1++;
+                code_pop_statement();
+            }
             /* if not, generate now */
             block = onfalse;
             goto tailcall;