ForLoopsLowering: Reduce unnecessary temporary variables for the
"checked step" (check for a positive step arg) and "negated step" (negate the step arg when the nested step is negative).
This commit is contained in:
committed by
Alexander Udalov
parent
291d62f653
commit
b1ce21bc55
+4
-5
@@ -12,18 +12,17 @@ fun box(): String {
|
||||
//
|
||||
// Expected lowered form of loop (before bytecode optimization):
|
||||
//
|
||||
// // Additional variables:
|
||||
// val newStep = throw IllegalArgumentException("Step must be positive, was: 0.")
|
||||
// // Additional statements:
|
||||
// throw IllegalArgumentException("Step must be positive, was: 0.")
|
||||
//
|
||||
// // Standard form of loop over progression
|
||||
// var inductionVar = 1u
|
||||
// val last = getProgressionLastElement(1u, 6u, newStep)
|
||||
// val step = newStep
|
||||
// val last = getProgressionLastElement(1u, 6u, 0)
|
||||
// if (inductionVar <= last) {
|
||||
// // Loop is not empty
|
||||
// do {
|
||||
// val i = inductionVar
|
||||
// inductionVar += step
|
||||
// inductionVar += 0
|
||||
// // Loop body
|
||||
// } while (i != last)
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user