From 8245dfa2d5c6e074d577d756f40243cd2c0363c7 Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 22 Jun 2023 20:17:21 +0200 Subject: misc fix --- optmem.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'optmem.c') diff --git a/optmem.c b/optmem.c index c9b4536..b5eaae4 100644 --- a/optmem.c +++ b/optmem.c @@ -49,25 +49,22 @@ deltrivialphis(struct block *blk, union ref phiref) same = UNDREF; /* the phi is unreachable or in the start block */ /* replace uses */ - replcins(phiref, same); + replcuses(phiref, same); - /* remove phi */ - for (int i = 0; i < blk->phi.n; ++i) { - if (blk->phi.p[i] == phiref.i) { - for (int k = i; k < blk->phi.n - 1; ++k) - blk->phi.p[k] = blk->phi.p[k + 1]; - --blk->phi.n; - break; - } - } instrtab[phiref.i].op = Onop; /* recursively try to remove all phi users as they might have become trivial */ for (use = instruse[phiref.i], uend = use + instrnuse[phiref.i]; use < uend; ++use) - if (use->u != USERJUMP && instrtab[use->u].op == Ophi && use->u != phiref.i) + if (use->u != USERJUMP && instrtab[use->u].op == Ophi) deltrivialphis(use->blk, mkref(RTMP, use->u)); - deluses(phiref.i); + /* remove phi */ + for (int i = 0; i < blk->phi.n; ++i) { + if (blk->phi.p[i] == phiref.i) { + delphi(blk, i); + break; + } + } return same; } @@ -187,7 +184,7 @@ mem2reg(struct function *fn) } } /* remove alloca */ - delinstr(blk, i); + delinstr(blk, i--); Next:; } -- cgit v1.2.3