]> de.git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Little optimization to not produce an unreachable goto instruction
authorWolfgang (Blub) Bumiller <blub@speed.at>
Wed, 21 Nov 2012 16:40:35 +0000 (17:40 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Wed, 21 Nov 2012 16:40:35 +0000 (17:40 +0100)
ir.c

diff --git a/ir.c b/ir.c
index bf0a7459120cb9ed2582832217ff8ec17b21d59c..232bd69d00531620b523a794638b3c2adb979ae0 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -2522,6 +2522,15 @@ tailcall:
                 /* fixup the jump address */
                 code_statements[stidx].o2.s1 = (onfalse->code_start) - (stidx);
                 stmt.opcode = vec_last(code_statements).opcode;
+                if (stmt.opcode == INSTR_GOTO ||
+                    stmt.opcode == INSTR_IF ||
+                    stmt.opcode == INSTR_IFNOT ||
+                    stmt.opcode == INSTR_RETURN ||
+                    stmt.opcode == INSTR_DONE)
+                {
+                    /* no use jumping from here */
+                    return true;
+                }
                 /* may have been generated in the previous recursive call */
                 stmt.opcode = INSTR_GOTO;
                 stmt.o1.s1 = (onfalse->code_start) - vec_size(code_statements);