Support Long and Char in const-bounded counter loop generation
If the loop end value is a compile-time constant (best we can do now), and it is safe to iterate over a given range using "naive" for loop (using '<=' or '>=' in loop condition), generate such loops for Longs and Chars as well Ints (Bytes, Shorts).
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
const val N = 42L
|
||||
|
||||
fun test(): Long {
|
||||
var sum = 0L
|
||||
for (i in 1L .. N) {
|
||||
sum += i
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
// 1 LCMP
|
||||
// 0 IFEQ
|
||||
// 1 IFGT
|
||||
Reference in New Issue
Block a user