ForLoopsLowering: Add PLUSEQ origin to increment to use IINC
instructions if possible.
This commit is contained in:
committed by
Alexander Udalov
parent
14137cb013
commit
8bc7370b92
@@ -0,0 +1,35 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun intRangeTo(a: Int, b: Int) { for (i in a .. b) {} }
|
||||
fun intRangeToStep(a: Int, b: Int) { for (i in a .. b step 127) {} } // Uses IADD in non-IR
|
||||
fun intDownTo(a: Int, b: Int) { for (i in a downTo b) {} }
|
||||
fun intDownToStep(a: Int, b: Int) { for (i in a downTo b step 128) {} } // Uses IADD in non-IR
|
||||
fun intUntil(a: Int, b: Int) { for (i in a until b) {} }
|
||||
|
||||
fun byteRangeToByte(a: Byte, b: Byte) { for (i in a .. b) {} }
|
||||
fun byteRangeToShort(a: Byte, b: Short) { for (i in a .. b) {} }
|
||||
fun byteRangeToInt(a: Byte, b: Int) { for (i in a .. b) {} }
|
||||
fun shortRangeToByte(a: Short, b: Byte) { for (i in a .. b) {} }
|
||||
fun shortRangeToShort(a: Short, b: Short) { for (i in a .. b) {} }
|
||||
fun shortRangeToInt(a: Short, b: Int) { for (i in a .. b) {} }
|
||||
fun intRangeToByte(a: Int, b: Byte) { for (i in a .. b) {} }
|
||||
fun intRangeToShort(a: Int, b: Short) { for (i in a .. b) {} }
|
||||
|
||||
fun uIntRangeTo(a: UInt, b: UInt) { for (i in a .. b) {} }
|
||||
fun uIntRangeToStep(a: UInt, b: UInt) { for (i in a .. b step 127) {} } // Uses IADD in non-IR
|
||||
fun uIntDownTo(a: UInt, b: UInt) { for (i in a downTo b) {} }
|
||||
fun uIntDownToStep(a: UInt, b: UInt) { for (i in a downTo b step 128) {} } // Uses IADD in non-IR
|
||||
fun uIntUntil(a: UInt, b: UInt) { for (i in a until b) {} }
|
||||
|
||||
fun uByteRangeTo(a: UByte, b: UByte) { for (i in a .. b) {} }
|
||||
fun uShortRangeTo(a: UShort, b: UShort) { for (i in a .. b) {} }
|
||||
|
||||
// 0 ISUB
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// 4 IADD
|
||||
// 16 IINC
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 IADD
|
||||
// 20 IINC
|
||||
-8
@@ -17,13 +17,5 @@ fun foo() {
|
||||
// 3 LLOAD
|
||||
// 1 MAXLOCALS = 10
|
||||
// 0 InlineMarker
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// fake inline variables occupy 7 ISTOREs.
|
||||
// 16 ISTORE
|
||||
// 11 ILOAD
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// JVM_IR generates an extra induction variable in 'for (i in 1..2)' (see KT-36837)
|
||||
// 19 ISTORE
|
||||
// 14 ILOAD
|
||||
|
||||
-8
@@ -18,13 +18,5 @@ fun test() {
|
||||
// 1 MAXLOCALS = 3
|
||||
// 1 MAXLOCALS = 4
|
||||
// 0 InlineMarker
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// fake inline variables occupy 7 ISTOREs.
|
||||
// 14 ISTORE
|
||||
// 7 ILOAD
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// JVM_IR generates an extra induction variable in 'for (i in 1..2)' (see KT-36837)
|
||||
// 17 ISTORE
|
||||
// 10 ILOAD
|
||||
|
||||
Reference in New Issue
Block a user