shithub: mc

Download patch

ref: df3be17970375f2a05281aad81734be0db8f4983
parent: 95a76e16ded89189df3f85bfbaf5d40088e5cd97
parent: 10a3edcf0264c6e2b878a230f4a77f8954b67d0d
author: Ori Bernstein <[email protected]>
date: Wed Feb 6 17:31:58 EST 2013

Merge in the nop move deletion.

--- a/6/ra.c
+++ b/6/ra.c
@@ -665,8 +665,6 @@
 {
     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 @@
     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 @@
     }
 
     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 @@
     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 @@
     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 @@
         bb->il = new;
         bb->ni = nnew;
     }
+    if (debugopt['r'])
+        dumpasm(s, stdout);
 }
 
 void regalloc(Isel *s)
@@ -1176,7 +1173,7 @@
         if (spilled)
             rewrite(s);
     } while (spilled);
-    deldup(s);
+    delnops(s);
     bsfree(s->prepainted);
     bsfree(s->shouldspill);
     bsfree(s->neverspill);
--- a/6/simp.c
+++ b/6/simp.c
@@ -342,6 +342,8 @@
 
     assert(e->type == Nexpr);
     t = gentemp(simp, e, e->expr.type, &dcl);
+    if (stacknode(e))
+        declarelocal(simp, dcl);
     return t;
 }