commit fb96623fc6a1919d7c1551b2a3e13f73265034b4
parent d9bc0a023ad88e2a8848db1c0577c224c1b00fa3
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sat, 21 Mar 2015 03:02:07 -0400
Fix moveto() reuse case
When moveto detects that register already contents
the symbol we are looking for it has to return.
Is is not the same and it is not used, then it must be
spilled.
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/cc2/cgen.c b/cc2/cgen.c
@@ -158,9 +158,9 @@ moveto(Node *np, uint8_t reg)
if (u) {
Symbol *sym = np->sym;
- if (op == u->op && sym && sym == u->sym)
+ if (sym && sym == u->sym)
return;
- else
+ else if (!np->used)
spill(reg);
}
@@ -349,6 +349,7 @@ assign(Node *np)
lp->used = 1;
np->op = REG;
np->reg = rp->reg;
+ np->sym = lp->sym;
}
static void