summaryrefslogtreecommitdiffhomepage
path: root/mrbgems
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-11-17 16:33:53 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-11-17 16:33:53 +0900
commitf5d9aab37227766b46c836871204d56c3c512801 (patch)
tree9814c263da7155f488859f9250bbd3263d170369 /mrbgems
parente3e54453a711461b9e39fa7c4fc6cbdd75120feb (diff)
downloadmruby-f5d9aab37227766b46c836871204d56c3c512801.tar.gz
mruby-f5d9aab37227766b46c836871204d56c3c512801.zip
codegen.c: should not emit the `MOVE` instruction to the same register.
Diffstat (limited to 'mrbgems')
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index 7edcd2029..013e65ee0 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -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;