summary refs log tree commit diff
diff options
context:
space:
mode:
authorEyal Sawady <ecs@d2evs.net>2021-08-13 08:15:49 +0000
committerQuentin Carbonneaux <quentin@c9x.me>2021-08-23 10:35:58 +0200
commit3cbad4d9c465d3f298cbe19c46f7c16f6a9b9f0f (patch)
treec622f86f57c5aa35b580af1fa643740e91e8a42f
parent2dd269f522298836796ff78390d0eb0e244e41f4 (diff)
downloadroux-3cbad4d9c465d3f298cbe19c46f7c16f6a9b9f0f.tar.gz
amd64/emit.c: fix %x =k sub %x, %x
The negate trick is unnecessary and broken when the first arg is the
result.
-rw-r--r--amd64/emit.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/amd64/emit.c b/amd64/emit.c
index 29b6bbb..09b90d5 100644
--- a/amd64/emit.c
+++ b/amd64/emit.c
@@ -408,7 +408,7 @@ emitins(Ins i, Fn *fn, FILE *f)
 	case Osub:
 		/* we have to use the negation trick to handle
 		 * some 3-address subtractions */
-		if (req(i.to, i.arg[1])) {
+		if (req(i.to, i.arg[1]) && !req(i.arg[0], i.to)) {
 			if (KBASE(i.cls) == 0)
 				emitf("neg%k %=", &i, fn, f);
 			else