commit 7ba69be87b3910cac2a8cd1cfe021e58f57f58d7
parent e6c216baadf89402a21b3eb60df1196e562df527
Author: Quentin Carbonneaux <quentin@c9x.me>
Date: Sun, 5 May 2019 14:34:17 +0200
fuse epilog deduplication with jump threading
Diffstat:
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/cfg.c b/cfg.c
@@ -297,12 +297,19 @@ simpljmp(Fn *fn)
{
Blk **uf; /* union-find */
- Blk *b;
+ Blk **p, *b, *ret;
int c;
+ ret = blknew();
+ ret->id = fn->nblk++;
+ ret->jmp.type = Jret0;
uf = emalloc(fn->nblk * sizeof uf[0]);
for (b=fn->start; b; b=b->link) {
assert(!b->phi);
+ if (b->jmp.type == Jret0) {
+ b->jmp.type = Jjmp;
+ b->s1 = ret;
+ }
if (b->nins == 0)
if (b->jmp.type == Jjmp) {
uffind(&b->s1, uf);
@@ -310,7 +317,7 @@ simpljmp(Fn *fn)
uf[b->id] = b->s1;
}
}
- for (b=fn->start; b; b=b->link) {
+ for (p=&fn->start; (b=*p); p=&b->link) {
if (b->s1)
uffind(&b->s1, uf);
if (b->s2)
@@ -322,5 +329,6 @@ simpljmp(Fn *fn)
b->s2 = 0;
}
}
+ *p = ret;
free(uf);
}
diff --git a/rega.c b/rega.c
@@ -417,10 +417,11 @@ doblk(Blk *b, RMap *cur)
}
for (r=0; r<nr; r++)
*ra[r] = ralloc(cur, ra[r]->val);
+ if (i->op == Ocopy && req(i->to, i->arg[0]))
+ curi++;
/* try to change the register of a hinted
* temporary if rf is available */
- x = 1;
if (rf != -1 && (t = cur->w[rf]) != 0)
if (!bshas(cur->b, rf) && *hint(t) == rf
&& (rt = rfree(cur, t)) != -1) {