summaryrefslogtreecommitdiffhomepage
path: root/src/codegen.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-08-29 16:24:12 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-08-29 16:24:12 +0900
commit607795ffdd4ea172de557d6e4983d87e011d7698 (patch)
tree88449b8a10d4cbbf24f6d57eafcaf0970a6902dd /src/codegen.c
parent3c4cd5428a1cfc43516f57506c1faf775c2a4abc (diff)
downloadmruby-607795ffdd4ea172de557d6e4983d87e011d7698.tar.gz
mruby-607795ffdd4ea172de557d6e4983d87e011d7698.zip
more OP_MOVE swap detection in peephole optimization
Diffstat (limited to 'src/codegen.c')
-rw-r--r--src/codegen.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/codegen.c b/src/codegen.c
index 78d641faf..bccc30cea 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -188,13 +188,13 @@ genop_peep(codegen_scope *s, mrb_code i, int val)
if (val) break;
switch (c0) {
case OP_MOVE:
- if (GETARG_B(i) == GETARG_A(i0) && GETARG_A(i) == GETARG_B(i0) && GETARG_A(i) >= s->nlocals) {
+ if (GETARG_B(i) == GETARG_A(i0) && GETARG_A(i) == GETARG_B(i0)) {
/* skip swapping OP_MOVE */
return 0;
}
if (GETARG_B(i) == GETARG_A(i0) && GETARG_A(i0) >= s->nlocals) {
- s->iseq[s->pc-1] = MKOP_AB(OP_MOVE, GETARG_A(i), GETARG_B(i0));
- return 0;
+ s->pc--;
+ return genop_peep(s, MKOP_AB(OP_MOVE, GETARG_A(i), GETARG_B(i0)), val);
}
break;
case OP_LOADI: