ref: 200e2387df6fa8f874a4504437b3787df5327368
parent: cd61580b6cd92002ac990c82a2efc27b674597b2
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Apr 25 18:29:16 EDT 2016
[cc2] Optimize jumps to jumps statements In this case of statements we are wasting time jumping to another jump. We can jump directly to the target jump.
--- a/cc2/optm.c
+++ b/cc2/optm.c
@@ -5,5 +5,15 @@
Node *
optm(Node *np)
{
+ Node *dst;
+
+ switch (np->op) {
+ case OJMP:
+ case OBRANCH:
+ dst = np->u.sym->u.stmt;
+ if (dst->op == OJMP)
+ np->u.sym = dst->u.sym;
+ break;
+ }
return np;
}
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -577,6 +577,7 @@
np->op = ONOP;
sym = np->u.sym;
sym->kind = SLABEL;
+ sym->u.stmt = np;
np->label = sym;
addstmt(np);
}