compile.c: optimize useless branches
* compile.c (iseq_peephole_optimize): eliminate always/never branches after a literal object and when the value is used after the branch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
53a619de6c
commit
792c822ec4
@ -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>
|
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
|
* configure.in: Add -D_XOPEN_SOURCE=500 (or 600 or 700) on Solaris
|
||||||
|
12
compile.c
12
compile.c
@ -2053,8 +2053,18 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
|
|||||||
* =>
|
* =>
|
||||||
* jump L1
|
* jump L1
|
||||||
*
|
*
|
||||||
|
* putstring ".."
|
||||||
|
* dup
|
||||||
|
* if L1
|
||||||
|
* =>
|
||||||
|
* putstring ".."
|
||||||
|
* jump L1
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
int cond;
|
int cond;
|
||||||
|
if (prev_dup && pobj->link.prev->type == ISEQ_ELEMENT_INSN) {
|
||||||
|
pobj = (INSN *)pobj->link.prev;
|
||||||
|
}
|
||||||
if (pobj->insn_id == BIN(putobject)) {
|
if (pobj->insn_id == BIN(putobject)) {
|
||||||
cond = (iobj->insn_id == BIN(branchif) ?
|
cond = (iobj->insn_id == BIN(branchif) ?
|
||||||
OPERAND_AT(pobj, 0) != Qfalse :
|
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);
|
cond = iobj->insn_id != BIN(branchif);
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
REMOVE_ELEM(&pobj->link);
|
REMOVE_ELEM(iobj->link.prev);
|
||||||
if (cond) {
|
if (cond) {
|
||||||
iobj->insn_id = BIN(jump);
|
iobj->insn_id = BIN(jump);
|
||||||
goto again;
|
goto again;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user