mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
compile.c: Partially revert r63870 which caused wrong optimization
[Bug #15906]
This commit is contained in:
parent
b8af33e63b
commit
a6a26e42b1
2 changed files with 17 additions and 1 deletions
|
@ -2735,7 +2735,8 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
|
|||
ELEM_INSERT_NEXT(&iobj->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);
|
||||
|
|
|
@ -795,6 +795,21 @@ class TestRubyOptimization < Test::Unit::TestCase
|
|||
assert_equal(:ok, x.bug(:ok))
|
||||
end
|
||||
|
||||
def test_jump_elimination_with_optimized_out_block_2
|
||||
x = Object.new
|
||||
def x.bug
|
||||
a = "aaa"
|
||||
ok = :NG
|
||||
if a == "bbb" || a == "ccc" then
|
||||
a = a
|
||||
else
|
||||
ok = :ok
|
||||
end
|
||||
ok
|
||||
end
|
||||
assert_equal(:ok, x.bug)
|
||||
end
|
||||
|
||||
def test_peephole_jump_after_newarray
|
||||
i = 0
|
||||
%w(1) || 2 while (i += 1) < 100
|
||||
|
|
Loading…
Reference in a new issue