diff options
| author | 2025-11-24 12:58:46 +0100 | |
|---|---|---|
| committer | 2025-11-24 12:58:46 +0100 | |
| commit | 5ba62d79923a48c1b1f6a8fc236650f5a8281844 (patch) | |
| tree | 7edc0d8828e1e5b71eb194b03672665e89ce754d /ir/ssa.c | |
| parent | 31122c856c193085d427dc74459847a280728805 (diff) | |
ir: simplify some occurrences of single-argument phis
Diffstat (limited to 'ir/ssa.c')
| -rw-r--r-- | ir/ssa.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -7,6 +7,16 @@ copyopt(struct function *fn) FREQUIRE(FNUSE); do { + if (blk->npred == 1) for (int i = 0; i < blk->phi.n; ++i) { + /* simplify 1-arg phi */ + int phi = blk->phi.p[i]; + union ref *arg = phitab.p[instrtab[phi].l.i]; + /* being conservative here because phis could have circular dependencies? */ + if (arg->t != RTMP || instrtab[arg->i].op != Ophi) { + replcuses(mkref(RTMP, phi), *arg); + delphi(blk, i--); + } + } for (int i = 0; i < blk->ins.n; ++i) { union ref var = mkref(RTMP, blk->ins.p[i]); struct instr *ins = &instrtab[var.i]; |