summary refs log tree commit diff
path: root/lisc
diff options
context:
space:
mode:
Diffstat (limited to 'lisc')
-rw-r--r--lisc/emit.c2
-rw-r--r--lisc/isel.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/lisc/emit.c b/lisc/emit.c
index d5b1e80..00bce4b 100644
--- a/lisc/emit.c
+++ b/lisc/emit.c
@@ -173,6 +173,8 @@ eins(Ins i, Fn *fn, FILE *f)
 		eop(otoa[i.op], i.arg[1], i.to, fn, f);
 		break;
 	case OCopy:
+		if (req(i.to, R))
+			break;
 		if (i.to.val < EAX && rtype(i.arg[0]) == RCon) {
 			val = fn->con[i.arg[0].val].val;
 			if (0 <= val && val <= UINT32_MAX) {
diff --git a/lisc/isel.c b/lisc/isel.c
index 6f2147f..97a0124 100644
--- a/lisc/isel.c
+++ b/lisc/isel.c
@@ -318,8 +318,11 @@ seljmp(Blk *b, Fn *fn)
 				selcmp(fi->arg, fn);
 				*fi = (Ins){ONop, R, {R, R}};
 			}
-		} else
+		} else {
+			if (fn->tmp[r.val].nuse == 1)
+				emit(OCopy, R, r, R);
 			b->jmp.type = JXJc + Cne;
+		}
 	} else {
 		selcmp((Ref[2]){r, CON_Z}, fn);
 		b->jmp.type = JXJc + Cne;