codegen.c: should not emit the MOVE instruction to the same register.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-11-17 16:33:53 +09:00
parent e3e54453a7
commit f5d9aab372
+2 -1
View File
@@ -577,6 +577,7 @@ static void
gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep)
{
if (nopeep || no_peephole(s)) goto normal;
else if (dst == src) return;
else {
struct mrb_insn_data data = mrb_last_insn(s);
@@ -1804,7 +1805,7 @@ gen_assignment(codegen_scope *s, node *tree, int sp, int val)
gen_call(s, tree, attrsym(s, nsym(tree->cdr->car)), sp, NOVAL,
type == NODE_SCALL);
pop();
if (val) {
if (val && cursp() != sp) {
gen_move(s, cursp(), sp, 0);
}
break;