aboutsummaryrefslogtreecommitdiffhomepage
path: root/amd64
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-20 19:52:35 +0200
committerlemon <lsof@mailbox.org>2023-06-20 19:52:35 +0200
commit42c7551e508e45cd4346e67898c374b910ee1407 (patch)
tree277adf9d6286803a9023c77b33e967525ea31c31 /amd64
parenta0de0318bbb41e9d51375a273fdad033ddd0ae90 (diff)
improve codegen for div a little (bikeshedding)
Diffstat (limited to 'amd64')
-rw-r--r--amd64/isel.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/amd64/isel.c b/amd64/isel.c
index 2273c99..b0cacea 100644
--- a/amd64/isel.c
+++ b/amd64/isel.c
@@ -224,6 +224,7 @@ static void
sel(struct function *fn, struct instr *ins, struct block *blk, int *curi)
{
uint siz, alignlog2;
+ int t;
struct instr temp = {0};
enum op op = ins->op;
@@ -290,6 +291,10 @@ sel(struct function *fn, struct instr *ins, struct block *blk, int *curi)
*ins = mkinstr(Ocopy, ins->cls, mkref(RREG, op < Orem ? RAX : RDX)); /* get output */
temp = mkinstr(Ocopy, ins->cls, mkref(RREG, op < Orem ? RDX : RAX)); /* clobber other reg*/
insertinstr(blk, ++(*curi), temp);
+ /* swap instrs so that clobber goes first */
+ t = blk->ins.p[*curi - 1];
+ blk->ins.p[*curi - 1] = blk->ins.p[*curi - 0];
+ blk->ins.p[*curi - 0] = t;
break;
case Osub:
if (ins->r.bits == mkref(RICON, 1).bits) {