[hackers] [scc] [cc2] Optimize jumps to jumps statements || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Wed, 27 Apr 2016 20:46:33 +0200 (CEST)

commit 975dc3570759c0609e8532e9dce4127d9216ac7b
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
AuthorDate: Mon Apr 25 22:29:16 2016 +0200
Commit: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
CommitDate: Tue Apr 26 20:02:08 2016 +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.

diff --git a/cc2/optm.c b/cc2/optm.c
index ffc4afa..12cecb1 100644
--- a/cc2/optm.c
+++ b/cc2/optm.c
_AT_@ -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
index 2cfb49e..89a9e48 100644
--- a/cc2/parser.c
+++ b/cc2/parser.c
_AT_@ -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);
 }
Received on Wed Apr 27 2016 - 20:46:33 CEST

This archive was generated by hypermail 2.3.0 : Wed Apr 27 2016 - 20:48:26 CEST