From 776be1b3979f25bedf742417fd1161ab552882cc Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 22 Feb 2022 19:27:47 +0900 Subject: [PATCH] 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`. --- mrbgems/mruby-compiler/core/codegen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index b36f80acc..4b9ff64df 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -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);