shithub: mc

Download patch

ref: c6f49171ce8b601b0b83ced09dfeb825fabf7233
parent: 0bcd350aa42cb4fa53f759fe333d194cd15e1246
author: Ori Bernstein <[email protected]>
date: Thu Jun 14 23:15:38 EDT 2012

Don't make a monotonically increasing live set.

    I missed a line in the translation of build()...

--- a/8/ra.c
+++ b/8/ra.c
@@ -265,7 +265,6 @@
     s->gadj = gadj;
 
     s->spilled = bsclear(s->spilled);
-    s->prepainted = bsclear(s->prepainted);
     s->coalesced = bsclear(s->coalesced);
     /*
     s->wlspill = bsclear(s->wlspill);
@@ -291,7 +290,6 @@
     Insn *insn;
     size_t l;
 
-    setup(s);
     /* set up convenience vars */
     bb = s->bb;
     nbb = s->nbb;
@@ -316,6 +314,7 @@
 		    lappend(&s->rmoves[d[k]], &s->nrmoves[d[k]], insn);
 		lappend(&s->wlmove, &s->nwlmove, insn);
 	    }
+	    /* live = live U def(i) */
 	    for (k = 0; k < nd; k++)
 		bsput(live, d[k]);
 
@@ -322,6 +321,11 @@
 	    for (k = 0; k < nd; k++)
 		for (l = 0; bsiter(live, &l); l++)
 		    addedge(s, d[k], l);
+	    /* live = use(i) U (live \ def(i)) */
+	    for (k = 0; k < nd; k++)
+		bsdel(live, d[k]);
+	    for (k = 0; k < nu; k++)
+		bsdel(live, u[k]);
 	}
     }
 }
@@ -376,8 +380,8 @@
     size_t i;
 
     for (i = 0; i < maxregid; i++) {
-	if (locmap[i]->reg.colour)
-	    bsput(s->prepainted, i);
+	if (bshas(s->prepainted, i))
+	    continue;
 	else if (s->degree[i] >= K)
 	    lappend(&s->wlspill, &s->nwlspill, locmap[i]);
 	else if (moverelated(s, i))
@@ -624,9 +628,15 @@
 
 void regalloc(Isel *s)
 {
+    size_t i;
     int spilled;
 
+    s->prepainted = mkbs();
+    for (i = 0; i < maxregid; i++)
+	if (locmap[i]->reg.colour)
+	    bsput(s->prepainted, i);
     do {
+	setup(s);
 	liveness(s);
 	build(s);
 	mkworklist(s);