commit 3cbad4d9c465d3f298cbe19c46f7c16f6a9b9f0f
parent 2dd269f522298836796ff78390d0eb0e244e41f4
Author: Eyal Sawady <ecs@d2evs.net>
Date: Fri, 13 Aug 2021 08:15:49 +0000
amd64/emit.c: fix %x =k sub %x, %x
The negate trick is unnecessary and broken when the first arg is the
result.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git 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