commit 8d0d2c097a87b8d96e107bab9b0c9176e75f89ef
parent 78ccf13a90596a1c132707c46679d62e2a18207b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sat, 21 Mar 2015 03:20:08 -0400
Improve assign() in cc2
Once a value is assigned, left and righ nodes contain the same
content, so both nodes (and the parent) contain a correct value
for the symbol (if any), so any of them can be used instead of
the symbol.
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/cc2/cgen.c b/cc2/cgen.c
@@ -333,6 +333,7 @@ assign(Node *np)
case AUTO:
if (rp->op != REG)
move(rp, np);
+ lp->reg = rp->reg;
code(LDL, lp, rp);
break;
case REG:
@@ -346,10 +347,10 @@ assign(Node *np)
abort();
}
- lp->used = 1;
np->op = REG;
- np->reg = rp->reg;
- np->sym = lp->sym;
+ np->reg = lp->reg;
+ np->sym = rp->sym = lp->sym;
+ np->used = rp->used = lp->used = 1;
}
static void