mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
last-exclusive progressions (i.e., "until" progressions and loop over array indices). This change makes it possible to correctly implement the handling of "step" progressions. Computing the last element of a stepped progression requires that the last is inclusive. Also invert the while loop (into if + do-while) that is used when lowering for-loops over progressions that cannot overflow. This keeps the performance characteristics closer to the ForLoopsLowering in kotlin-native, since the goal is to converge to this shared version. Also used IrType instead of KotlinType, where possible. https://github.com/JetBrains/kotlin/pull/2390 https://github.com/JetBrains/kotlin/pull/2305
25 lines
329 B
Kotlin
Vendored
25 lines
329 B
Kotlin
Vendored
// IGNORE_BACKEND: JVM_IR
|
|
const val N = 42L
|
|
|
|
fun test(): Long {
|
|
var sum = 0L
|
|
for (i in 1L .. N) {
|
|
sum += i
|
|
}
|
|
return sum
|
|
}
|
|
|
|
// JVM non-IR uses while.
|
|
// JVM IR uses if + do-while.
|
|
|
|
// 0 iterator
|
|
// 0 getStart
|
|
// 0 getEnd
|
|
// 0 getFirst
|
|
// 0 getLast
|
|
// 0 getStep
|
|
// 1 LCMP
|
|
// 1 IFGT
|
|
// 1 IF
|
|
// 0 L2I
|
|
// 0 I2L |