From b02aecc21e951484fcb2702f2e3328e76cd9064d Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 6 Jul 2023 20:47:26 +0200 Subject: fix emit() setcc and copy --- amd64/emit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'amd64') diff --git a/amd64/emit.c b/amd64/emit.c index 8f3286a..088809d 100644 --- a/amd64/emit.c +++ b/amd64/emit.c @@ -632,7 +632,7 @@ Xsetcc(uchar **pcode, enum cc cc, enum reg reg) if (in_range(reg, RSP, RDI)) rex = 0x40; rex |= (reg >> 3); /* REX.B */ - if (rex) B(rex); + if (rex) B(rex | 0x40); B(0x0F), B(0x90+cc); /* SETcc */ B(0xC0 + (reg & 7)); /* ModR/M with mod=11, rm=reg */ @@ -687,6 +687,7 @@ gencopy(uchar **pcode, enum irclass cls, struct block *blk, int curi, struct ope * which may clobber flags */ const struct addr *addr = &addrht[val.i]; if (flagslivep(blk, curi)) goto Lea; + if (addr->base.t != RREG) goto Lea; if (addr->base.bits && dst.reg == mkregoper(addr->base).reg) { /* base = dst */ if (addr->index.bits && !addr->disp && !addr->shift){ /* lea Rx, [Rx + Ry] -> add Rx, Ry */ -- cgit v1.2.3