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:
Mark Punzalan
2020-07-16 00:42:36 -07:00
committed by Alexander Udalov
parent 291d62f653
commit b1ce21bc55
29 changed files with 153 additions and 173 deletions
@@ -12,19 +12,18 @@ fun box(): String {
//
// Expected lowered form of loop (before bytecode optimizations):
//
// // Additional variables:
// // Additional statements:
// val untilArg = nine()
// val nestedLast = untilArg - 1
//
// // Standard form of loop over progression
// var inductionVar = 1
// val last = getProgressionLastElement(1, nestedLast, 2)
// val step = 2
// if (untilArg != Int.MIN_VALUE && inductionVar <= last) {
// // Loop is not empty
// do {
// val i = inductionVar
// inductionVar += step
// inductionVar += 2
// // Loop body
// } while (i != last)
// }