KT-22334 Specialized loops using range such as integer..array.size-1

- Into PrimitiveNumberRangeLiteralRangeValue modifies how bounded
value are created by checking if the high bound range can be modified
to be exclusive instead of inclusive such as the generated code will
be optimized.
- Add black box tests checking that the specialization does not fail
on any kind of arrays.
- Add a bytecode test checking that the code is correctly optimized.

Fix of https://youtrack.jetbrains.com/issue/KT-22334
This commit is contained in:
Mikaël Peltier
2018-02-02 13:48:41 +01:00
committed by Dmitry Petrov
parent 8c8caa4707
commit 8676ca34d7
8 changed files with 236 additions and 3 deletions

View File

@@ -0,0 +1,12 @@
fun test(): Int {
val intArray = intArrayOf(1, 2, 3)
var sum = 0
for (i in 0..intArray.size-1) {
sum += intArray[i]
}
return sum
}
// 1 IF_ICMPGE
// 0 IF_ICMPGT
// 0 IF_ICMPEQ