commit 5dcf8c14cbefb3f96262e5fbe5168cfe48e6fd3a
parent 66288673cdce588bf81612c0599047665afefce7
Author: Quentin Carbonneaux <quentin@c9x.me>
Date: Tue, 6 Jun 2017 10:09:31 -0400
fix floating-point division
It never worked until today.
Diffstat:
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/amd64/emit.c b/amd64/emit.c
@@ -405,6 +405,16 @@ emitins(Ins i, Fn *fn, FILE *f)
break;
}
goto Table;
+ case Odiv:
+ /* adjust the instruction when the conversion to
+ * a 2-address division is impossible */
+ if (req(i.to, i.arg[1])) {
+ i.arg[1] = TMP(XMM0+15);
+ emitf("mov%k %=, %1", &i, fn, f);
+ emitf("mov%k %0, %=", &i, fn, f);
+ i.arg[0] = i.to;
+ }
+ goto Table;
case Ocopy:
/* make sure we don't emit useless copies,
* also, we can use a trick to load 64-bits
diff --git a/amd64/isel.c b/amd64/isel.c
@@ -200,6 +200,8 @@ sel(Ins i, ANum *an, Fn *fn)
case Orem:
case Oudiv:
case Ourem:
+ if (KBASE(k) == 1)
+ goto Emit;
if (i.op == Odiv || i.op == Oudiv)
r0 = TMP(RAX), r1 = TMP(RDX);
else