diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-11-09 22:11:03 -0500 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-11-09 22:19:07 -0500 |
commit | 8f91dfb44ab4a304a9a6703b7624c2336c132cdb (patch) | |
tree | 712eb7d82c1caf54b0c4298c15f3728a29904444 | |
parent | 8ed8f1cd4c8251c6aba3f694b711179a44c91397 (diff) | |
download | roux-8f91dfb44ab4a304a9a6703b7624c2336c132cdb.tar.gz |
do not insert dead phis
-rw-r--r-- | lisc/ssa.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/lisc/ssa.c b/lisc/ssa.c index d31cfad..82b7a72 100644 --- a/lisc/ssa.c +++ b/lisc/ssa.c @@ -194,8 +194,8 @@ index(int t, Fn *fn) static void phiins(Fn *fn) { - Bits u; - Blk *b, **blist, **be, **bp; + Bits u, defs; + Blk *a, *b, **blist, **be, **bp; Ins *i; Phi *p; Ref r; @@ -213,7 +213,7 @@ phiins(Fn *fn) for (b=fn->start; b; b=b->link) { b->visit = 0; r = R; - for (i=b->ins; i-b->ins < b->nins; i++) { + for (i=b->ins; i!=&b->ins[b->nins]; i++) { if (!req(r, R)) { if (req(i->arg[0], TMP(t))) i->arg[0] = r; @@ -241,22 +241,26 @@ phiins(Fn *fn) } } } + defs = u; while (bp != be) { b = *bp++; BCLR(u, b->id); - if (b->visit) - continue; - b->visit = 1; - p = alloc(sizeof *p); - p->wide = w; - p->to = TMP(t); - p->link = b->phi; - b->phi = p->link; - for (n=0; n<b->nfron; n++) - if (!BGET(u, b->fron[n]->id)) { - BSET(u, b->fron[n]->id); - *--bp = b->fron[n]; + for (n=0; n<b->nfron; n++) { + a = b->fron[n]; + if (a->visit++ == 0) + if (BGET(a->in, t)) { + p = alloc(sizeof *p); + p->wide = w; + p->to = TMP(t); + p->link = a->phi; + a->phi = p->link; + if (!BGET(defs, a->id)) + if (!BGET(u, a->id)) { + BSET(u, a->id); + *--bp = a; + } } + } } } free(blist); @@ -265,8 +269,13 @@ phiins(Fn *fn) void ssa(Fn *fn) { + int d; + + d = debug['L']; + debug['L'] = 0; filldom(fn); fillfron(fn); filllive(fn); phiins(fn); + debug['L'] = d; } |