From 3cbad4d9c465d3f298cbe19c46f7c16f6a9b9f0f Mon Sep 17 00:00:00 2001 From: Eyal Sawady Date: Fri, 13 Aug 2021 08:15:49 +0000 Subject: amd64/emit.c: fix %x =k sub %x, %x The negate trick is unnecessary and broken when the first arg is the result. --- amd64/emit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'amd64') 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 -- cgit 1.4.1