summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-28 02:02:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-28 02:02:40 +0000
commitd6fdd1c3306889794267558e9003a11a96a73477 (patch)
tree745867297c68b5fa22fbafe76c523a472869d9cc
parent8cbb7747cd46b1c798fc778686bba720e0068218 (diff)
compile.c: splatarray peephole opt
* compile.c (iseq_peephole_optimize): remove splatarray following always-array insn. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--compile.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index b113b08df4..3eed0fd6e5 100644
--- a/compile.c
+++ b/compile.c
@@ -2256,6 +2256,26 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
}
+ if (IS_INSN_ID(iobj, newarray) ||
+ IS_INSN_ID(iobj, duparray) ||
+ IS_INSN_ID(iobj, expandarray) ||
+ IS_INSN_ID(iobj, concatarray) ||
+ IS_INSN_ID(iobj, splatarray) ||
+ 0) {
+ /*
+ * newarray N
+ * splatarray
+ * =>
+ * newarray N
+ * newarray always puts an array
+ */
+ LINK_ELEMENT *next = iobj->link.next;
+ if (IS_INSN(next) && IS_INSN_ID(next, splatarray)) {
+ /* remove splatarray following always-array insn */
+ REMOVE_ELEM(next);
+ }
+ }
+
if (do_tailcallopt &&
(IS_INSN_ID(iobj, send) ||
IS_INSN_ID(iobj, opt_aref_with) ||