From e5983ba1a2174fe7fd004692a427aae5bfc0dc4c Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Wed, 5 Aug 2015 21:46:15 -0400 Subject: fix 2 bad bugs in rega and improve substraction The substraction contrained the register allocator to allocate a different register for the result and the second operand, now, we use a neg trick to compile it down. The machinery that was setup is, regardless, interesting and will have to be used for floating point computations (division). The first bug in rega made broke the explicited loop invariant: we were using register allocation unavailable information from other blocks. It's still unclear how we got wrong results from that considering mappings are all 0-initialized. The second bug is a stupid one, one sizeof operator was missing from a memcpy... --- lisc/spill.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'lisc/spill.c') diff --git a/lisc/spill.c b/lisc/spill.c index 8b7c67e..7361b11 100644 --- a/lisc/spill.c +++ b/lisc/spill.c @@ -361,22 +361,7 @@ spill(Fn *fn) case -1:; } w = (Bits){{0}}; - if (rtype(i->arg[1]) == RTmp - && !req(i->to, R) - && opdesc[i->op].comm == F) { - /* - * here we make sure that we - * will never have to compile - * say: eax = sub ebx, eax - * on a two-address machine - */ - BSET(w, i->to.val); - BSET(v, i->to.val); - setloc(&i->arg[1], &v, &w); - BCLR(v, i->to.val); - BCLR(w, i->to.val); - } else - setloc(&i->arg[1], &v, &w); + setloc(&i->arg[1], &v, &w); setloc(&i->arg[0], &v, &w); if (s) emit(OStore, R, i->to, SLOT(s)); -- cgit 1.4.1