diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-08-29 16:24:12 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-08-29 16:24:12 +0900 |
| commit | 607795ffdd4ea172de557d6e4983d87e011d7698 (patch) | |
| tree | 88449b8a10d4cbbf24f6d57eafcaf0970a6902dd | |
| parent | 3c4cd5428a1cfc43516f57506c1faf775c2a4abc (diff) | |
| download | mruby-607795ffdd4ea172de557d6e4983d87e011d7698.tar.gz mruby-607795ffdd4ea172de557d6e4983d87e011d7698.zip | |
more OP_MOVE swap detection in peephole optimization
| -rw-r--r-- | src/codegen.c | 6 |
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: |
