Simplify some basic instructions using peephole optimization

DUP_X1; POP = SWAP

p1_a; p1_b; SWAP = p1_b; p1_a
where p1_a, p1_b are instructions without side effects pushing value of
size 1 on stack.
E.g.: ACONST_NULL; ALOAD 0; SWAP = ALOAD 0; ACONST_NULL

NOP; NOP = NOP
This commit is contained in:
Dmitry Petrov
2017-07-06 12:23:58 +03:00
parent 224848163d
commit ea95f31f99
4 changed files with 126 additions and 96 deletions

View File

@@ -3,8 +3,5 @@
fun testPrimitiveArray(ints: IntArray) =
10 in ints.indices
// We currently fail to optimize this method because of DUP_X1 instruction generated for range check.
// TODO either don't generate DUP_X1/DUP2_X2 instructions for range checks (extra local variable + extra instructions),
// or support DUPn_Xm instructions in PopBackwardPropagationTransformer
// - 0 DUP
// - 0 POP
// 0 DUP
// 0 POP