From b6afdd647ce394dc7e1281cc42c05b6981cd62b2 Mon Sep 17 00:00:00 2001 From: lemon Date: Sun, 19 Oct 2025 11:07:07 +0200 Subject: codegen bugfixes --- ir/regalloc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ir/regalloc.c') diff --git a/ir/regalloc.c b/ir/regalloc.c index 64dcfac..1e23a8a 100644 --- a/ir/regalloc.c +++ b/ir/regalloc.c @@ -1026,7 +1026,8 @@ devirt(struct rega *ra, struct block *blk) insertinstr(blk, ++curi, mkinstr(store, 0, .r = mkref(RREG, reg))).i, alloc->a*8); } - } else if (!ins->reg && insrescls(*ins) && ins->op != Omove && !ins->keep) { + } + if (!ins->reg && insrescls(*ins) && ins->op != Omove && !ins->keep) { /* dead */ Nop: ins->op = Onop; @@ -1036,12 +1037,15 @@ devirt(struct rega *ra, struct block *blk) } else if (ins->op == Ocopy && ins->l.t == RREG && ins->reg-1 == ins->l.i) { /* r1 = copy r2 / r1=r2 */ goto Nop; - } else if (ins->inplace && ins->l.t == RREG && ins->reg && ins->reg-1 != ins->l.i) { + } else if (ins->op != Onop) { + allnops = 0; + } + if (ins->inplace && ins->l.t == RREG && ins->reg && ins->reg-1 != ins->l.i) { /* fixup in-place (two-address) instructions */ allnops = 0; insertinstr(blk, curi++, mkmove(ins->cls, ins->reg-1, ins->l.i)); ins->l.i = ins->reg-1; - } else if (ins->op != Onop) allnops = 0; + } } return allnops; -- cgit v1.2.3