codegen.c: fixed a bug in OP_LOADI32 peephole optimization.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-07-23 11:20:18 +09:00
parent 598c97ef76
commit 9c43276eb5
+9 -1
View File
@@ -488,11 +488,19 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep)
s->pc = s->lastpc;
genop_2(s, data.insn, dst, data.b);
break;
case OP_GETUPVAR: case OP_LOADI32:
case OP_GETUPVAR:
if (nopeep || data.a != src || data.a < s->nlocals) goto normal;
s->pc = s->lastpc;
genop_3(s, data.insn, dst, data.b, data.c);
break;
case OP_LOADI32:
if (nopeep || data.a != src || data.a < s->nlocals) goto normal;
else {
uint32_t i = (uint32_t)data.b<<16|data.c;
s->pc = s->lastpc;
genop_2SS(s, data.insn, dst, i);
}
break;
default:
goto normal;
}