diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-06 04:52:33 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-07-06 04:52:33 +0000 |
commit | e59abe944f2d792823aad4400bb8bc8fc685c1b6 (patch) | |
tree | 2d73229ec1046f44646376f3d524d9bb1788fb00 /compile.c | |
parent | 2d1e109f5f42920da666fd5302d71ad96e526faa (diff) | |
download | ruby-e59abe944f2d792823aad4400bb8bc8fc685c1b6.tar.gz |
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
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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); |