aboutsummaryrefslogtreecommitdiffhomepage
path: root/amd64/isel.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-17 23:26:45 +0200
committerlemon <lsof@mailbox.org>2023-06-17 23:26:45 +0200
commit962ad175aee634274b408ead38b13e6bc90e2fe7 (patch)
treecfda733adf56ed12e829f594e0b6d66f0a1a7a70 /amd64/isel.c
parentec28e9057e84b92acabb7ebf9122af59738917ad (diff)
basic ELF output
Diffstat (limited to 'amd64/isel.c')
-rw-r--r--amd64/isel.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/amd64/isel.c b/amd64/isel.c
index 7725013..0205313 100644
--- a/amd64/isel.c
+++ b/amd64/isel.c
@@ -202,7 +202,15 @@ sel(struct function *fn, struct instr *ins, struct block *blk, int *curi)
}
goto ALU;
case Oadd:
- if (ins->l.bits == mkref(RICON, 1).bits) {
+ if (kisint(ins->cls) && (addarg4addrp(ins->l) || addarg4addrp(ins->r))) {
+ temp.op = Ocopy;
+ temp.cls = ins->cls;
+ temp.l = mkref(RTMP, ins - instrtab);
+ if (fuseaddr(fn, &temp.l)) {
+ *ins = temp;
+ break;
+ }
+ } else if (ins->l.bits == mkref(RICON, 1).bits) {
/* add 1,x -> inc x */
ins->op = op = Oxinc;
ins->l = ins->r;
@@ -213,14 +221,6 @@ sel(struct function *fn, struct instr *ins, struct block *blk, int *curi)
ins->op = op = Oxinc;
ins->r = NOREF;
goto ALU;
- } else if (kisint(ins->cls) && (addarg4addrp(ins->l) || addarg4addrp(ins->r))) {
- temp.op = Ocopy;
- temp.cls = ins->cls;
- temp.l = mkref(RTMP, ins - instrtab);
- if (fuseaddr(fn, &temp.l)) {
- *ins = temp;
- break;
- }
}
/* fallthru */
case Omul: case Oumul: