From fd6d911b5382283ae375e6ae6256543070469a26 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 8 Oct 2021 12:09:05 +0900 Subject: codegen.c: peephole optimize `OP_MOVE` after `OP_ARRAY` or `OP_HASH`. When the length operand is zero, we don't need `OP_MOVE` but adjust the destination operand instead. --- mrbgems/mruby-compiler/core/codegen.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 5197cc7fe..5d23b2dd4 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -594,6 +594,9 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep) rewind_pc(s); genop_1(s, data.insn, dst); return; + case OP_HASH: case OP_ARRAY: + if (data.b != 0) goto normal; + /* fall through */ case OP_LOADI: case OP_LOADINEG: case OP_LOADL: case OP_LOADSYM: case OP_GETGV: case OP_GETSV: case OP_GETIV: case OP_GETCV: -- cgit v1.2.3