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.
parent 70182864
...@@ -594,6 +594,9 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep) ...@@ -594,6 +594,9 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep)
rewind_pc(s); rewind_pc(s);
genop_1(s, data.insn, dst); genop_1(s, data.insn, dst);
return; return;
case OP_HASH: case OP_ARRAY:
if (data.b != 0) goto normal;
/* fall through */
case OP_LOADI: case OP_LOADINEG: case OP_LOADI: case OP_LOADINEG:
case OP_LOADL: case OP_LOADSYM: case OP_LOADL: case OP_LOADSYM:
case OP_GETGV: case OP_GETSV: case OP_GETIV: case OP_GETCV: case OP_GETGV: case OP_GETSV: case OP_GETIV: case OP_GETCV:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment