aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2026-04-09 09:54:58 +0200
committerlemon <lsof@mailbox.org>2026-04-09 09:54:58 +0200
commit53c789eb351e0281026d7145dc6dbc83338d7aa8 (patch)
tree7cae7377e019fd3cb82d1998883745ee2c40cad1
parent2c777a84d54fec374f95034d2b823d92be6e8658 (diff)
x86-64/isel: use integer stores for storing float constants
Because the integer mov can have immediate operands, avoids a round trip through an XMM register.
-rw-r--r--src/t_x86-64_isel.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/t_x86-64_isel.c b/src/t_x86-64_isel.c
index 0e3c55d..f4e4523 100644
--- a/src/t_x86-64_isel.c
+++ b/src/t_x86-64_isel.c
@@ -339,7 +339,7 @@ loadstoreaddr(Block *blk, Ref *r, int *curi)
picfixsym(r, blk, curi);
} else if (r->t == RSTACK || (r->t == RTMP && addarg4addrp(*r))) {
fuseaddr(r, blk, curi);
- } else if (r->t != RREG) {
+ } else if (r->t != RREG && r->t != RTMP) {
*r = insertinstr(blk, (*curi)++, mkinstr1(Ocopy, KPTR, *r));
}
}
@@ -501,7 +501,21 @@ sel(Function *fn, Instr *ins, Block *blk, int *curi)
case Oloads32: case Oloadu32: case Oloadi64: case Oloadf32: case Oloadf64:
loadstoreaddr(blk, &ins->l, curi);
break;
- case Ostorei8: case Ostorei16: case Ostorei32: case Ostorei64: case Ostoref32: case Ostoref64:
+ case Ostoref32: case Ostoref64:
+ if (isfltcon(ins->r)) {
+ /* for storing float constants, use the integer store instrs since they can
+ * have immediate operands */
+ if (concls(ins->r) == KF64) {
+ s64int pun = intconval(ins->r);
+ ins->r = mkintcon(KI64, pun);
+ } else {
+ union { float f; int i; } pun = { fltconval(ins->r) };
+ ins->r = mkintcon(KI32, pun.i);
+ }
+ ins->op = op = Ostorei32 + (op - Ostoref32);
+ }
+ /* fallthru */
+ case Ostorei8: case Ostorei16: case Ostorei32: case Ostorei64:
loadstoreaddr(blk, &ins->l, curi);
if (isaddrcon(ins->r,1) || ins->r.t == RADDR || ins->r.t == RSTACK)
ins->r = insertinstr(blk, (*curi)++, mkinstr1(Ocopy, KPTR, ins->r));