aboutsummaryrefslogtreecommitdiff
path: root/spill.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <[email protected]>2016-12-21 09:56:40 -0500
committerQuentin Carbonneaux <[email protected]>2016-12-21 09:56:40 -0500
commit3c3afdc896be4de996d7486e40e7b81488b745b9 (patch)
treeee630a1d0754103dd726fc06cd50ea2cb2134e9b /spill.c
parentd04ba5eae886ce4e5407ccd711fb1c9846dcf1f7 (diff)
schedule loop nesting computations earlier
Diffstat (limited to 'spill.c')
-rw-r--r--spill.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/spill.c b/spill.c
index f9dcc49..5d1726e 100644
--- a/spill.c
+++ b/spill.c
@@ -1,23 +1,16 @@
#include "all.h"
static void
-loopmark(Blk *hd, Blk *b)
+aggreg(Blk *hd, Blk *b)
{
int k;
- uint n;
- if (b->id < hd->id || b->visit == hd->id)
- return;
- b->visit = hd->id;
- b->loop *= 10;
/* aggregate looping information at
* loop headers */
bsunion(hd->gen, b->gen);
for (k=0; k<2; k++)
if (b->nlive[k] > hd->nlive[k])
hd->nlive[k] = b->nlive[k];
- for (n=0; n<b->npred; n++)
- loopmark(hd, b->pred[n]);
}
static void
@@ -46,32 +39,26 @@ tmpuse(Ref r, int use, int loop, Fn *fn)
void
fillcost(Fn *fn)
{
- int n, hd;
+ int n;
uint a;
Blk *b;
Ins *i;
Tmp *t;
Phi *p;
- for (b=fn->start; b; b=b->link) {
- b->loop = 1;
- b->visit = -1;
- }
- if (debug['S'])
+ loopiter(fn, aggreg);
+ if (debug['S']) {
fprintf(stderr, "\n> Loop information:\n");
- for (n=0; n<fn->nblk; n++) {
- b = fn->rpo[n];
- hd = 0;
- for (a=0; a<b->npred; a++)
- if (b->pred[a]->id >= n) {
- loopmark(b, b->pred[a]);
- hd = 1;
+ for (b=fn->start; b; b=b->link) {
+ for (a=0; a<b->npred; ++a)
+ if (b->id <= b->pred[a]->id)
+ break;
+ if (a != b->npred) {
+ fprintf(stderr, "\t%-10s", b->name);
+ fprintf(stderr, " (% 3d ", b->nlive[0]);
+ fprintf(stderr, "% 3d) ", b->nlive[1]);
+ dumpts(b->gen, fn->tmp, stderr);
}
- if (hd && debug['S']) {
- fprintf(stderr, "\t%-10s", b->name);
- fprintf(stderr, " (% 3d ", b->nlive[0]);
- fprintf(stderr, "% 3d) ", b->nlive[1]);
- dumpts(b->gen, fn->tmp, stderr);
}
}
for (t=fn->tmp; t-fn->tmp < fn->ntmp; t++) {