summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lisc/emit.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lisc/emit.c b/lisc/emit.c
index 59b439b..278f579 100644
--- a/lisc/emit.c
+++ b/lisc/emit.c
@@ -261,6 +261,11 @@ eins(Ins i, Fn *fn, FILE *f)
 		break;
 	case OXCmpw:
 	case OXCmpl:
+		if (rtype(i.arg[1]) == RTmp && req(i.arg[0], CON_Z)) {
+			eop("test", i.arg[1], i.arg[1], fn, f);
+			break;
+		}
+		/* fall through */
 	case OXTestw:
 	case OXTestl:
 		eop(otoa[i.op], i.arg[0], i.arg[1], fn, f);