ruby-changes:48225
From: nobu <ko1@a...>
Date: Sun, 22 Oct 2017 10:46:48 +0900 (JST)
Subject: [ruby-changes:48225] nobu:r60340 (trunk): compile.c: optimize local variable assignments
nobu 2017-10-22 10:46:43 +0900 (Sun, 22 Oct 2017) New Revision: 60340 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60340 Log: compile.c: optimize local variable assignments * compile.c (iseq_peephole_optimize): eliminate simple self assignments of a local variable when the result is used. follow-up of r60322. Modified files: trunk/compile.c Index: compile.c =================================================================== --- compile.c (revision 60339) +++ compile.c (revision 60340) @@ -2597,12 +2597,16 @@ iseq_peephole_optimize(rb_iseq_t *iseq, https://github.com/ruby/ruby/blob/trunk/compile.c#L2597 } if (IS_INSN_ID(iobj, getlocal)) { - if (IS_NEXT_INSN_ID(&iobj->link, setlocal)) { - LINK_ELEMENT *set1 = iobj->link.next; + LINK_ELEMENT *niobj = &iobj->link; + if (IS_NEXT_INSN_ID(niobj, dup)) { + niobj = niobj->next; + } + if (IS_NEXT_INSN_ID(niobj, setlocal)) { + LINK_ELEMENT *set1 = niobj->next; if (OPERAND_AT(iobj, 0) == OPERAND_AT(set1, 0) && OPERAND_AT(iobj, 1) == OPERAND_AT(set1, 1)) { REMOVE_ELEM(set1); - REMOVE_ELEM(&iobj->link); + REMOVE_ELEM(niobj); } } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/