Don't generate DUPX instructions for in-range-literal expressions

Store argument into a local variable instead.
This commit is contained in:
Dmitry Petrov
2017-10-24 11:03:53 +03:00
parent 9b49e9139c
commit 354d54aef6
7 changed files with 170 additions and 146 deletions
@@ -0,0 +1,12 @@
// WITH_RUNTIME
fun test(a: Int) = a in 1 .. 10
fun test(a: Long) = a in 1L .. 10L
fun test(a: Float) = a in 1.0f .. 10.0f
fun test(a: Double) = a in 1.0 .. 10.0
fun test(a: String) = a in "abc" .. "def"
// 0 DUP_X1
// 0 DUP2_X1
// 0 DUP_X2
// 0 DUP2_X2
@@ -1,7 +0,0 @@
// WITH_RUNTIME
fun test(a: Long) = a in 1L .. 10L
// One DUP2_X2 generated for 'in' operator,
// no DUP2_X2 generated for range on stack.
// 1 DUP2_X2