mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix a bug of peephole optimization
``` if L1 L0: jump L2 L1: ... L2: ``` was wrongly optimized to: ``` unless L2 L0: L1: ... L2: ``` To make it conservative, this optimization is now disabled when there is any label between `if` and `jump` instructions. Fixes [Bug #14897]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fcf8c622fd
commit
727ceb2a95
2 changed files with 12 additions and 1 deletions
|
@ -589,3 +589,13 @@ assert_equal "foo", %q{
|
|||
end
|
||||
Bug6460.new.m1
|
||||
}, '[ruby-dev:46372]'
|
||||
|
||||
assert_equal "foo", %q{
|
||||
obj = "foo"
|
||||
if obj || any1
|
||||
any2 = any2
|
||||
else
|
||||
raise obj.inspect
|
||||
end
|
||||
obj
|
||||
}, '[ruby-core:87830]'
|
||||
|
|
|
@ -2730,7 +2730,8 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
|
|||
ELEM_INSERT_NEXT(&dniobj->link, &pop->link);
|
||||
goto again;
|
||||
}
|
||||
else if ((piobj = (INSN *)get_prev_insn(iobj)) != 0 &&
|
||||
else if (IS_INSN(iobj->link.prev) &&
|
||||
(piobj = (INSN *)iobj->link.prev) &&
|
||||
(IS_INSN_ID(piobj, branchif) ||
|
||||
IS_INSN_ID(piobj, branchunless))) {
|
||||
INSN *pdiobj = (INSN *)get_destination_insn(piobj);
|
||||
|
|
Loading…
Reference in a new issue