diff options
author | Quentin Carbonneaux <quentin@c9x.me> | 2019-05-05 14:34:17 +0200 |
---|---|---|
committer | Quentin Carbonneaux <quentin@c9x.me> | 2019-05-05 15:19:32 +0200 |
commit | 7ba69be87b3910cac2a8cd1cfe021e58f57f58d7 (patch) | |
tree | c249b56245d420a788dbc2e82a1adb2feeddeb7c /cfg.c | |
parent | e6c216baadf89402a21b3eb60df1196e562df527 (diff) | |
download | roux-7ba69be87b3910cac2a8cd1cfe021e58f57f58d7.tar.gz |
fuse epilog deduplication with jump threading
Diffstat (limited to 'cfg.c')
-rw-r--r-- | cfg.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cfg.c b/cfg.c index b1c80c7..81da842 100644 --- 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); } |