codegen.c: use OP_ARRAY instead of OP_ARRAY2 in optimization.

If operand 1 and operand 2 specify the same register `OP_ARRAY2`
can/should be transformed to `OP_ARRAY`.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-02-22 19:27:47 +09:00
parent d4d29b21b3
commit 776be1b397
+1 -1
View File
@@ -634,7 +634,7 @@ gen_move(codegen_scope *s, uint16_t dst, uint16_t src, int nopeep)
case OP_ARRAY:
if (data.a != src || data.a < s->nlocals || data.a < dst) goto normal;
rewind_pc(s);
if (data.b == 0)
if (data.b == 0 || dst == data.a)
genop_2(s, OP_ARRAY, dst, 0);
else
genop_3(s, OP_ARRAY2, dst, data.a, data.b);