aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-29 10:14:11 +0100
committerlemon <lsof@mailbox.org>2025-12-29 10:14:11 +0100
commit984486a87f37cbd0d6a31bee38c0bc05d86d5bf9 (patch)
treed4d17ec5095f4d6c300021c16e07e24a4b7a1c5b
parent1151d095ac459244671ea2f12af4638f4c5cc701 (diff)
x86_64: optimize away some redundant zero extensions
-rw-r--r--x86_64/isel.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/x86_64/isel.c b/x86_64/isel.c
index a3c1c79..d69f9ad 100644
--- a/x86_64/isel.c
+++ b/x86_64/isel.c
@@ -516,9 +516,17 @@ sel(struct function *fn, struct instr *ins, struct block *blk, int *curi)
ins->op = Oextu32;
} else assert(!"nyi flt -> u64");
break;
+ case Oextu32:
+ if (ins->l.t == RTMP && insrescls(instrtab[ins->l.i]) == KI32 && instrtab[ins->l.i].op != Ocopy) {
+ /* no need to explicitly zero extend 32 -> 64bit regs in x86-64 */
+ /* this copy can be optimized away in regalloc */
+ ins->op = op = Ocopy;
+ ins->cls = KI32;
+ }
+ /* fallthru */
case Ocvtf32f64: case Ocvtf64f32: case Ocvtf32s: case Ocvtf64s: case Ocvts32f: case Ocvts64f:
case Ocvtu64f:
- case Oexts8: case Oextu8: case Oexts16: case Oextu16: case Oexts32: case Oextu32:
+ case Oexts8: case Oextu8: case Oexts16: case Oextu16: case Oexts32:
if (isnumcon(ins->l)) {
union ref it;
bool ok = foldunop(&it, ins->op, ins->cls, ins->l);