Browse Source

amd64/emit.c: fix %x =k sub %x, %x

The negate trick is unnecessary and broken when the first arg is the
result.
Eyal Sawady 4 years ago
parent
commit
3cbad4d9c4
1 changed files with 1 additions and 1 deletions
  1. 1 1
      amd64/emit.c

+ 1 - 1
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