summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lisc/spill.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/lisc/spill.c b/lisc/spill.c
index 40bd326..7f967e4 100644
--- a/lisc/spill.c
+++ b/lisc/spill.c
@@ -31,14 +31,20 @@ loopmark(Blk *hd, Blk *b, Phi *p)
 static void
 tmpuse(Ref r, int use, int loop, Fn *fn)
 {
+	Mem *m;
 	Tmp *t;
 
-	if (rtype(r) != RTmp || r.val < Tmp0)
-		return;
-	t = &fn->tmp[r.val];
-	t->nuse += use;
-	t->ndef += !use;
-	t->cost += loop;
+	if (rtype(r) == RAMem) {
+		m = &fn->mem[r.val & AMask];
+		tmpuse(m->base, 1, loop, fn);
+		tmpuse(m->index, 1, loop, fn);
+	}
+	else if (rtype(r) == RTmp && r.val >= Tmp0) {
+		t = &fn->tmp[r.val];
+		t->nuse += use;
+		t->ndef += !use;
+		t->cost += loop;
+	}
 }
 
 /* evaluate spill costs of temporaries,