From 995fd23ecd5de710a6f587d29af2874b1fb4756d Mon Sep 17 00:00:00 2001 From: lemon Date: Wed, 21 Jun 2023 12:32:32 +0200 Subject: explicitly store predecessors in each block --- regalloc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'regalloc.c') diff --git a/regalloc.c b/regalloc.c index a30ebe5..19df61c 100644 --- a/regalloc.c +++ b/regalloc.c @@ -368,16 +368,16 @@ regalloc(struct function *fn) } } for (int i = blk->phi.n - 1; i >= 0; --i) { - struct phi *phi; + union ref *phi; ins = &instrtab[blk->phi.p[i]]; assert(ins->op == Ophi); - phi = &phitab.p[ins->l.i]; + phi = phitab.p[ins->l.i]; if (ins->reg) { /* introduce necessary moves in each pred, * XXX this doesn't work for backwards branches */ - for (int i = 0; i < phi->n; ++i) { - struct instr mov = mkinstr(Omove, insrescls(*ins), mkref(RREG, ins->reg-1), phi->ref[i]); - insertinstr(phi->blk[i], phi->blk[i]->ins.n, mov); + for (int i = 0; i < blk->npred; ++i) { + struct instr mov = mkinstr(Omove, insrescls(*ins), mkref(RREG, ins->reg-1), phi[i]); + insertinstr(blkpred(blk, i), blkpred(blk, i)->ins.n, mov); } } def(&ra, ins, NULL, 0); -- cgit v1.2.3