scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit 975dc3570759c0609e8532e9dce4127d9216ac7b
parent 950cfce031fb38e6337e087c398dc4e7c5efc467
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
Date:   Mon, 25 Apr 2016 22:29:16 +0200

[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.

Diffstat:
cc2/optm.c | 10++++++++++
cc2/parser.c | 1+
2 files changed, 11 insertions(+), 0 deletions(-)

diff --git 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; } diff --git a/cc2/parser.c b/cc2/parser.c @@ -577,6 +577,7 @@ labeldcl(void) np->op = ONOP; sym = np->u.sym; sym->kind = SLABEL; + sym->u.stmt = np; np->label = sym; addstmt(np); }