diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/range/forLoop/ForInSimpleProgressionLoopGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/range/forLoop/ForInSimpleProgressionLoopGenerator.kt index 9779875a25c..29a706eb214 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/range/forLoop/ForInSimpleProgressionLoopGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/range/forLoop/ForInSimpleProgressionLoopGenerator.kt @@ -77,10 +77,20 @@ class ForInSimpleProgressionLoopGenerator( v.load(endVar, asmElementType) if (asmElementType.sort == Type.LONG) { v.lcmp() - v.ifge(loopExit) + if (step > 0) { + v.ifge(loopExit) + } + else { + v.ifle(loopExit) + } } else { - v.ificmpge(loopExit) + if (step > 0) { + v.ificmpge(loopExit) + } + else { + v.ificmple(loopExit) + } } } }