summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <orib@google.com>2013-02-06 22:31:58 -0500
committerOri Bernstein <orib@google.com>2013-02-06 22:32:01 -0500
commitdf3be17970375f2a05281aad81734be0db8f4983 (patch)
tree85f9d91f7ff545a0666ffc19cc09987c19ce59f7
parent95a76e16ded89189df3f85bfbaf5d40088e5cd97 (diff)
parent10a3edcf0264c6e2b878a230f4a77f8954b67d0d (diff)
downloadmc-df3be17970375f2a05281aad81734be0db8f4983.tar.gz
Merge in the nop move deletion.
-rw-r--r--6/ra.c31
-rw-r--r--6/simp.c2
2 files changed, 16 insertions, 17 deletions
diff --git a/6/ra.c b/6/ra.c
index 7c7cda7..e8bceda 100644
--- a/6/ra.c
+++ b/6/ra.c
@@ -665,8 +665,6 @@ static int combinable(Isel *s, regid u, regid v)
{
regid t;
- if (debugopt['r'])
- printf("check combinable %zd <=> %zd\n", u, v);
/* Regs of different modes can't be combined as things stand.
* In principle they should be combinable, but it confused the
* whole mode dance. */
@@ -690,7 +688,7 @@ static void combine(Isel *s, regid u, regid v)
size_t i, j;
int has;
- if (debugopt['r'])
+ if (debugopt['r'] > 2)
printedge(stdout, "combining:", u, v);
if (wlhas(s->wlfreeze, s->nwlfreeze, v, &idx))
ldel(&s->wlfreeze, &s->nwlfreeze, idx);
@@ -714,7 +712,7 @@ static void combine(Isel *s, regid u, regid v)
}
for (t = 0; adjiter(s, v, &t); t++) {
- if (debugopt['r'])
+ if (debugopt['r'] > 2)
printedge(stdout, "combine-putedge:", t, u);
addedge(s, t, u);
decdegree(s, t);
@@ -1027,17 +1025,6 @@ static void rewritebb(Isel *s, Asmbb *bb)
nnew = 0;
for (j = 0; j < bb->ni; j++) {
insn = bb->il[j];
- /*
- if (ismove(insn)) {
- if (getalias(s, insn->args[0]->reg.id) == getalias(s, insn->args[1]->reg.id)) {
- if (debugopt['r']) {
- printf("dropping ");
- iprintf(stdout, insn);
- }
- continue;
- }
- }
- */
/* if there is a remapping, insert the loads and stores as needed */
if (remap(s, bb->il[j], use, &nuse, def, &ndef)) {
for (i = 0; i < nuse; i++) {
@@ -1114,7 +1101,15 @@ static void rewrite(Isel *s)
bsclear(s->spilled);
}
-void deldup(Isel *s)
+/*
+ * Coalescing registers leaves a lot
+ * of moves that look like
+ *
+ * mov %r123,%r123.
+ *
+ * This is useless. This deletes them.
+ */
+static void delnops(Isel *s)
{
Insn *insn;
Asmbb *bb;
@@ -1136,6 +1131,8 @@ void deldup(Isel *s)
bb->il = new;
bb->ni = nnew;
}
+ if (debugopt['r'])
+ dumpasm(s, stdout);
}
void regalloc(Isel *s)
@@ -1176,7 +1173,7 @@ void regalloc(Isel *s)
if (spilled)
rewrite(s);
} while (spilled);
- deldup(s);
+ delnops(s);
bsfree(s->prepainted);
bsfree(s->shouldspill);
bsfree(s->neverspill);
diff --git a/6/simp.c b/6/simp.c
index d24183e..7312c6e 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -342,6 +342,8 @@ static Node *temp(Simp *simp, Node *e)
assert(e->type == Nexpr);
t = gentemp(simp, e, e->expr.type, &dcl);
+ if (stacknode(e))
+ declarelocal(simp, dcl);
return t;
}