ref: fcb6d6ec65fb82c3b6b936dd148df72b9955994b
parent: 1d902b24b710d385033e1e6b8069bf8c48bf477f
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Mar 11 13:34:03 EDT 2024
7c: fix storeprop() sign extension bug when replacing sequences like: MOV r1, v # r1 = 0x1122334480000000 MOVW v, r2 # r2 = 0xffffffff80000000 -- MOV r1, v MOVW r1, r2 we need to actually sign extend to simulate the full effect of a MOVW load: MOV r1, v SXTW r1, r2 not doing this caused a regression in audio/oggenc, causing a immediate crash. also, reg->reg MOVW's are subject for elemination by subprop().
--- a/sys/src/cmd/7c/peep.c
+++ b/sys/src/cmd/7c/peep.c
@@ -266,6 +266,7 @@
case AMOVH:
case AMOVBU:
case AMOVHU:
+ case ASXTW:
if(p1->to.type == p->from.type && p1->to.reg == p->from.reg)
p->as = AMOVW;
break;
@@ -962,6 +963,8 @@
|| (as == AMOVW && p->as == AMOVWU)
|| (as == AMOVWU && p->as == AMOVW))
&& copyas(&p->from, v)){
+ if(p->as == AMOVW)
+ p->as = ASXTW;
p->from = *a;
continue;
}