diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | compile.c | 12 |
2 files changed, 17 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Sun Nov 22 16:37:10 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * compile.c (iseq_peephole_optimize): eliminate always/never + branches after a literal object and when the value is used after + the branch. + Sun Nov 22 01:23:43 2015 Naohisa Goto <ngotogenome@gmail.com> * configure.in: Add -D_XOPEN_SOURCE=500 (or 600 or 700) on Solaris @@ -2053,8 +2053,18 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal * => * jump L1 * + * putstring ".." + * dup + * if L1 + * => + * putstring ".." + * jump L1 + * */ int cond; + if (prev_dup && pobj->link.prev->type == ISEQ_ELEMENT_INSN) { + pobj = (INSN *)pobj->link.prev; + } if (pobj->insn_id == BIN(putobject)) { cond = (iobj->insn_id == BIN(branchif) ? OPERAND_AT(pobj, 0) != Qfalse : @@ -2069,7 +2079,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal cond = iobj->insn_id != BIN(branchif); } else break; - REMOVE_ELEM(&pobj->link); + REMOVE_ELEM(iobj->link.prev); if (cond) { iobj->insn_id = BIN(jump); goto again; |