diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompare.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompare.kt deleted file mode 100644 index f85ebce76de..00000000000 --- a/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompare.kt +++ /dev/null @@ -1,123 +0,0 @@ -// Generates ICONST_1 -val a = 1 - -fun main() { - // Negated == comparisons - // Generates IF_ICMPEQ and GOTO - if (!(a == 42)) { - "then" - } else { - "else" - } - - // Generates IF_ICMPEQ and GOTO - while (!(a == 42)) { - "loop" - } - - // Generates IF_ICMPNE - do { - "loop" - } while (!(a == 42)) - - // != comparisons - // Generates IF_ICMPEQ and GOTO - if (a != 42) { - "then" - } else { - "else" - } - - // Generates IF_ICMPEQ and GOTO - while (a != 42) { - "loop" - } - - // Generates IF_ICMPNE - do { - "loop" - } while (a != 42) - - // Negated > comparisons - // Generates IF_ICMPGT and GOTO - if (!(a > 42)) { - "then" - } else { - "else" - } - - // Generates IF_ICMPGT and GOTO - while (!(a > 42)) { - "loop" - } - - // Generates IF_ICMPLE - do { - "loop" - } while (!(a > 42)) - - // Negated >= comparisons - // Generates IF_ICMPGE and GOTO - if (!(a >= 42)) { - "then" - } else { - "else" - } - - // Generates IF_ICMPGE and GOTO - while (!(a >= 42)) { - "loop" - } - - // Generates IF_ICMPLT - do { - "loop" - } while (!(a >= 42)) - - // Negated < comparisons - // Generates IF_ICMPLT and GOTO - if (!(a < 42)) { - "then" - } else { - "else" - } - - // Generates IF_ICMPLT and GOTO - while (!(a < 42)) { - "loop" - } - - // Generates IF_ICMPGE - do { - "loop" - } while (!(a < 42)) - - // Negated <= comparisons - // Generates IF_ICMPLE and GOTO - if (!(a <= 42)) { - "then" - } else { - "else" - } - - // Generates IF_ICMPLE and GOTO - while (!(a <= 42)) { - "loop" - } - - // Generates IF_ICMPGT - do { - "loop" - } while (!(a <= 42)) -} - -//0 ICONST_0 -//1 ICONST_1 -//2 IF_ICMPNE -//4 IF_ICMPEQ -//3 IF_ICMPLE -//3 IF_ICMPLT -//3 IF_ICMPGE -//3 IF_ICMPGT -//18 IF -//12 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInDoWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInDoWhile.kt new file mode 100644 index 00000000000..207882efda1 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInDoWhile.kt @@ -0,0 +1,44 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IF_ICMPNE + do { + "loop" + } while (!(a == 42)) + + // Generates IF_ICMPNE + do { + "loop" + } while (a != 42) + + // Generates IF_ICMPLE + do { + "loop" + } while (!(a > 42)) + + // Generates IF_ICMPLT + do { + "loop" + } while (!(a >= 42)) + + // Generates IF_ICMPGE + do { + "loop" + } while (!(a < 42)) + + // Generates IF_ICMPGT + do { + "loop" + } while (!(a <= 42)) +} + +//0 ICONST_0 +//1 ICONST_1 +//2 IF_ICMPNE +//1 IF_ICMPLE +//1 IF_ICMPLT +//1 IF_ICMPGE +//1 IF_ICMPGT +//6 IF +//0 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInIf.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInIf.kt new file mode 100644 index 00000000000..8dc147e23dd --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInIf.kt @@ -0,0 +1,56 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IF_ICMPEQ and GOTO + if (!(a == 42)) { + "then" + } else { + "else" + } + + // Generates IF_ICMPEQ and GOTO + if (a != 42) { + "then" + } else { + "else" + } + + // Generates IF_ICMPGT and GOTO + if (!(a > 42)) { + "then" + } else { + "else" + } + + // Generates IF_ICMPGE and GOTO + if (!(a >= 42)) { + "then" + } else { + "else" + } + + // Generates IF_ICMPLT and GOTO + if (!(a < 42)) { + "then" + } else { + "else" + } + + // Generates IF_ICMPLE and GOTO + if (!(a <= 42)) { + "then" + } else { + "else" + } +} + +//0 ICONST_0 +//1 ICONST_1 +//2 IF_ICMPEQ +//1 IF_ICMPLE +//1 IF_ICMPLT +//1 IF_ICMPGE +//1 IF_ICMPGT +//6 IF +//6 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInWhile.kt new file mode 100644 index 00000000000..9e25012f53c --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInWhile.kt @@ -0,0 +1,44 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IF_ICMPEQ and GOTO + while (!(a == 42)) { + "loop" + } + + // Generates IF_ICMPEQ and GOTO + while (a != 42) { + "loop" + } + + // Generates IF_ICMPGT and GOTO + while (!(a > 42)) { + "loop" + } + + // Generates IF_ICMPGE and GOTO + while (!(a >= 42)) { + "loop" + } + + // Generates IF_ICMPLT and GOTO + while (!(a < 42)) { + "loop" + } + + // Generates IF_ICMPLE and GOTO + while (!(a <= 42)) { + "loop" + } +} + +//0 ICONST_0 +//1 ICONST_1 +//2 IF_ICMPEQ +//1 IF_ICMPLE +//1 IF_ICMPLT +//1 IF_ICMPGE +//1 IF_ICMPGT +//6 IF +//6 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompare.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompare.kt deleted file mode 100644 index d6ab83fc7a5..00000000000 --- a/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompare.kt +++ /dev/null @@ -1,45 +0,0 @@ -fun main(p: String?, p2: String?) { - // Negated == null comparisons - // Generates IFNULL and GOTO - if (!(p == null)) { - "then" - } else { - "else" - } - - // Generates IFNULL and GOTO - while (!(p == null)) { - "loop" - } - - // Generates IFNONNULL - do { - "loop" - } while (!(p == null)) - - // != null comparisons - // Generates IFNULL and GOTO - if (p2 != null) { - "then" - } else { - "else" - } - - // Generates IFNULL and GOTO - while (p2 != null) { - "loop" - } - - // Generates IFNONNULL - do { - "loop" - } while (p2 != null) -} - -//0 ICONST_0 -//0 ICONST_1 -//0 ACONST_NULL -//4 IFNULL -//2 IFNONNULL -//6 IF -//4 GOTO diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInDoWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInDoWhile.kt new file mode 100644 index 00000000000..283565e1517 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInDoWhile.kt @@ -0,0 +1,18 @@ +fun main(p: String?, p2: String?) { + // Generates IFNONNULL + do { + "loop" + } while (!(p == null)) + + // Generates IFNONNULL + do { + "loop" + } while (p2 != null) +} + +//0 ICONST_0 +//0 ICONST_1 +//0 ACONST_NULL +//2 IFNONNULL +//2 IF +//0 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInIf.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInIf.kt new file mode 100644 index 00000000000..46bac112fac --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInIf.kt @@ -0,0 +1,22 @@ +fun main(p: String?, p2: String?) { + // Generates IFNULL and GOTO + if (!(p == null)) { + "then" + } else { + "else" + } + + // Generates IFNULL and GOTO + if (p2 != null) { + "then" + } else { + "else" + } +} + +//0 ICONST_0 +//0 ICONST_1 +//0 ACONST_NULL +//2 IFNULL +//2 IF +//2 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInWhile.kt new file mode 100644 index 00000000000..dc992ee7afd --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInWhile.kt @@ -0,0 +1,18 @@ +fun main(p: String?, p2: String?) { + // Generates IFNULL and GOTO + while (!(p == null)) { + "loop" + } + + // Generates IFNULL and GOTO + while (p2 != null) { + "loop" + } +} + +//0 ICONST_0 +//0 ICONST_1 +//0 ACONST_NULL +//2 IFNULL +//2 IF +//2 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompare.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompare.kt deleted file mode 100644 index c9907c116c0..00000000000 --- a/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompare.kt +++ /dev/null @@ -1,123 +0,0 @@ -// Generates ICONST_1 -val a = 1 - -fun main() { - // Negated == comparisons - // Generates IFEQ and GOTO - if (!(a == 0)) { - "then" - } else { - "else" - } - - // Generates IFEQ and GOTO - while (!(a == 0)) { - "loop" - } - - // Generates IFNE - do { - "loop" - } while (!(a == 0)) - - // != comparisons - // Generates IFEQ and GOTO - if (a != 0) { - "then" - } else { - "else" - } - - // Generates IFEQ and GOTO - while (a != 0) { - "loop" - } - - // Generates IFNE - do { - "loop" - } while (a != 0) - - // Negated > comparisons - // Generates IFGT and GOTO - if (!(a > 0)) { - "then" - } else { - "else" - } - - // Generates IFGT and GOTO - while (!(a > 0)) { - "loop" - } - - // Generates IFLE - do { - "loop" - } while (!(a > 0)) - - // Negated >= comparisons - // Generates IFGE and GOTO - if (!(a >= 0)) { - "then" - } else { - "else" - } - - // Generates IFGE and GOTO - while (!(a >= 0)) { - "loop" - } - - // Generates IFLT - do { - "loop" - } while (!(a >= 0)) - - // Negated < comparisons - // Generates IFLT and GOTO - if (!(a < 0)) { - "then" - } else { - "else" - } - - // Generates IFLT and GOTO - while (!(a < 0)) { - "loop" - } - - // Generates IFGE - do { - "loop" - } while (!(a < 0)) - - // Negated <= comparisons - // Generates IFLE and GOTO - if (!(a <= 0)) { - "then" - } else { - "else" - } - - // Generates IFLE and GOTO - while (!(a <= 0)) { - "loop" - } - - // Generates IFGT - do { - "loop" - } while (!(a <= 0)) -} - -//0 ICONST_0 -//1 ICONST_1 -//2 IFNE -//4 IFEQ -//3 IFLE -//3 IFLT -//3 IFGE -//3 IFGT -//18 IF -//12 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInDoWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInDoWhile.kt new file mode 100644 index 00000000000..d5a5c834186 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInDoWhile.kt @@ -0,0 +1,44 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IFNE + do { + "loop" + } while (!(a == 0)) + + // Generates IFNE + do { + "loop" + } while (a != 0) + + // Generates IFLE + do { + "loop" + } while (!(a > 0)) + + // Generates IFLT + do { + "loop" + } while (!(a >= 0)) + + // Generates IFGE + do { + "loop" + } while (!(a < 0)) + + // Generates IFGT + do { + "loop" + } while (!(a <= 0)) +} + +//0 ICONST_0 +//1 ICONST_1 +//2 IFNE +//1 IFLE +//1 IFLT +//1 IFGE +//1 IFGT +//6 IF +//0 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInIf.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInIf.kt new file mode 100644 index 00000000000..a5c00dab1ca --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInIf.kt @@ -0,0 +1,56 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IFEQ and GOTO + if (!(a == 0)) { + "then" + } else { + "else" + } + + // Generates IFEQ and GOTO + if (a != 0) { + "then" + } else { + "else" + } + + // Generates IFGT and GOTO + if (!(a > 0)) { + "then" + } else { + "else" + } + + // Generates IFGE and GOTO + if (!(a >= 0)) { + "then" + } else { + "else" + } + + // Generates IFLT and GOTO + if (!(a < 0)) { + "then" + } else { + "else" + } + + // Generates IFLE and GOTO + if (!(a <= 0)) { + "then" + } else { + "else" + } +} + +//0 ICONST_0 +//1 ICONST_1 +//2 IFEQ +//1 IFLE +//1 IFLT +//1 IFGE +//1 IFGT +//6 IF +//6 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInWhile.kt new file mode 100644 index 00000000000..7f1347762ba --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInWhile.kt @@ -0,0 +1,44 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IFEQ and GOTO + while (!(a == 0)) { + "loop" + } + + // Generates IFEQ and GOTO + while (a != 0) { + "loop" + } + + // Generates IFGT and GOTO + while (!(a > 0)) { + "loop" + } + + // Generates IFGE and GOTO + while (!(a >= 0)) { + "loop" + } + + // Generates IFLT and GOTO + while (!(a < 0)) { + "loop" + } + + // Generates IFLE and GOTO + while (!(a <= 0)) { + "loop" + } +} + +//0 ICONST_0 +//1 ICONST_1 +//2 IFEQ +//1 IFLE +//1 IFLT +//1 IFGE +//1 IFGT +//6 IF +//6 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompare.kt b/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompare.kt deleted file mode 100644 index cbf0281103e..00000000000 --- a/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompare.kt +++ /dev/null @@ -1,105 +0,0 @@ -// Generates ICONST_1 -val a = 1 - -fun main() { - // == comparisons - // Generates IF_ICMPNE and GOTO - if (a == 42) { - "then" - } else { - "else" - } - - // Generates IF_ICMPNE and GOTO - while (a == 42) { - "loop" - } - - // Generates IF_ICMPEQ - do { - "loop" - } while (a == 42) - - // > comparisons - // Generates IF_ICMPLE and GOTO - if (a > 42) { - "then" - } else { - "else" - } - - // Generates IF_ICMPLE and GOTO - while (a > 42) { - "loop" - } - - // Generates IF_ICMPGT - do { - "loop" - } while (a > 42) - - // >= comparisons - // Generates IF_ICMPLT and GOTO - if (a >= 42) { - "then" - } else { - "else" - } - - // Generates IF_ICMPLT and GOTO - while (a >= 42) { - "loop" - } - - // Generates IF_ICMPGE - do { - "loop" - } while (a >= 42) - - // < comparisons - // Generates IF_ICMPGE and GOTO - if (a < 42) { - "then" - } else { - "else" - } - - // Generates IF_ICMPGE and GOTO - while (a < 42) { - "loop" - } - - // Generates IF_ICMPLT - do { - "loop" - } while (a < 42) - - // <= comparisons - // Generates IF_ICMPGT and GOTO - if (a <= 42) { - "then" - } else { - "else" - } - - // Generates IF_ICMPGT and GOTO - while (a <= 42) { - "loop" - } - - // Generates IF_ICMPLE - do { - "loop" - } while (a <= 42) -} - -//0 ICONST_0 -//1 ICONST_1 -//2 IF_ICMPNE -//1 IF_ICMPEQ -//3 IF_ICMPLE -//3 IF_ICMPLT -//3 IF_ICMPGE -//3 IF_ICMPGT -//15 IF -//10 GOTO diff --git a/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInDoWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInDoWhile.kt new file mode 100644 index 00000000000..ee4ba46641a --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInDoWhile.kt @@ -0,0 +1,39 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IF_ICMPEQ + do { + "loop" + } while (a == 42) + + // Generates IF_ICMPGT + do { + "loop" + } while (a > 42) + + // Generates IF_ICMPGE + do { + "loop" + } while (a >= 42) + + // Generates IF_ICMPLT + do { + "loop" + } while (a < 42) + + // Generates IF_ICMPLE + do { + "loop" + } while (a <= 42) +} + +//0 ICONST_0 +//1 ICONST_1 +//1 IF_ICMPEQ +//1 IF_ICMPLE +//1 IF_ICMPLT +//1 IF_ICMPGE +//1 IF_ICMPGT +//5 IF +//0 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInIf.kt b/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInIf.kt new file mode 100644 index 00000000000..0c5e164fc34 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInIf.kt @@ -0,0 +1,49 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IF_ICMPNE and GOTO + if (a == 42) { + "then" + } else { + "else" + } + + // Generates IF_ICMPLE and GOTO + if (a > 42) { + "then" + } else { + "else" + } + + // Generates IF_ICMPLT and GOTO + if (a >= 42) { + "then" + } else { + "else" + } + + // Generates IF_ICMPGE and GOTO + if (a < 42) { + "then" + } else { + "else" + } + + // Generates IF_ICMPGT and GOTO + if (a <= 42) { + "then" + } else { + "else" + } +} + +//0 ICONST_0 +//1 ICONST_1 +//1 IF_ICMPNE +//1 IF_ICMPLE +//1 IF_ICMPLT +//1 IF_ICMPGE +//1 IF_ICMPGT +//5 IF +//5 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInWhile.kt new file mode 100644 index 00000000000..8a00f861ed0 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInWhile.kt @@ -0,0 +1,39 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IF_ICMPNE and GOTO + while (a == 42) { + "loop" + } + + // Generates IF_ICMPLE and GOTO + while (a > 42) { + "loop" + } + + // Generates IF_ICMPLT and GOTO + while (a >= 42) { + "loop" + } + + // Generates IF_ICMPGE and GOTO + while (a < 42) { + "loop" + } + + // Generates IF_ICMPGT and GOTO + while (a <= 42) { + "loop" + } +} + +//0 ICONST_0 +//1 ICONST_1 +//1 IF_ICMPNE +//1 IF_ICMPLE +//1 IF_ICMPLT +//1 IF_ICMPGE +//1 IF_ICMPGT +//5 IF +//5 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/nullCompare.kt b/compiler/testData/codegen/bytecodeText/conditions/nullCompare.kt deleted file mode 100644 index fb39c38c964..00000000000 --- a/compiler/testData/codegen/bytecodeText/conditions/nullCompare.kt +++ /dev/null @@ -1,26 +0,0 @@ -fun main(p: String?) { - // Generates IFNONNULL and GOTO - if (p == null) { - "then" - } else { - "else" - } - - // Generates IFNONNULL and GOTO - while (p == null) { - "loop" - } - - // Generates IFNULL - do { - "loop" - } while (p == null) -} - -//0 ICONST_0 -//0 ICONST_1 -//0 ACONST_NULL -//2 IFNONNULL -//1 IFNULL -//3 IF -//2 GOTO diff --git a/compiler/testData/codegen/bytecodeText/conditions/nullCompareInDoWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/nullCompareInDoWhile.kt new file mode 100644 index 00000000000..8007bfa69f0 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/nullCompareInDoWhile.kt @@ -0,0 +1,13 @@ +fun main(p: String?) { + // Generates IFNULL + do { + "loop" + } while (p == null) +} + +//0 ICONST_0 +//0 ICONST_1 +//0 ACONST_NULL +//1 IFNULL +//1 IF +//0 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/nullCompareInIf.kt b/compiler/testData/codegen/bytecodeText/conditions/nullCompareInIf.kt new file mode 100644 index 00000000000..4d770307272 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/nullCompareInIf.kt @@ -0,0 +1,15 @@ +fun main(p: String?) { + // Generates IFNONNULL and GOTO + if (p == null) { + "then" + } else { + "else" + } +} + +//0 ICONST_0 +//0 ICONST_1 +//0 ACONST_NULL +//1 IFNONNULL +//1 IF +//1 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/nullCompareInWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/nullCompareInWhile.kt new file mode 100644 index 00000000000..df9750fc4ae --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/nullCompareInWhile.kt @@ -0,0 +1,13 @@ +fun main(p: String?) { + // Generates IFNONNULL and GOTO + while (p == null) { + "loop" + } +} + +//0 ICONST_0 +//0 ICONST_1 +//0 ACONST_NULL +//1 IFNONNULL +//1 IF +//1 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/zeroCompare.kt b/compiler/testData/codegen/bytecodeText/conditions/zeroCompare.kt deleted file mode 100644 index 5172b1d8b1a..00000000000 --- a/compiler/testData/codegen/bytecodeText/conditions/zeroCompare.kt +++ /dev/null @@ -1,105 +0,0 @@ -// Generates ICONST_1 -val a = 1 - -fun main() { - // == comparisons - // Generates IFNE and GOTO - if (a == 0) { - "then" - } else { - "else" - } - - // Generates IFNE and GOTO - while (a == 0) { - "loop" - } - - // Generates IFEQ - do { - "loop" - } while (a == 0) - - // > comparisons - // Generates IFLE and GOTO - if (a > 0) { - "then" - } else { - "else" - } - - // Generates IFLE and GOTO - while (a > 0) { - "loop" - } - - // Generates IFGT - do { - "loop" - } while (a > 0) - - // >= comparisons - // Generates IFLT and GOTO - if (a >= 0) { - "then" - } else { - "else" - } - - // Generates IFLT and GOTO - while (a >= 0) { - "loop" - } - - // Generates IFGE - do { - "loop" - } while (a >= 0) - - // < comparisons - // Generates IFGE and GOTO - if (a < 0) { - "then" - } else { - "else" - } - - // Generates IFGE and GOTO - while (a < 0) { - "loop" - } - - // Generates IFLT - do { - "loop" - } while (a < 0) - - // <= comparisons - // Generates IFGT and GOTO - if (a <= 0) { - "then" - } else { - "else" - } - - // Generates IFGT and GOTO - while (a <= 0) { - "loop" - } - - // Generates IFLE - do { - "loop" - } while (a <= 0) -} - -//0 ICONST_0 -//1 ICONST_1 -//2 IFNE -//1 IFEQ -//3 IFLE -//3 IFLT -//3 IFGE -//3 IFGT -//15 IF -//10 GOTO diff --git a/compiler/testData/codegen/bytecodeText/conditions/zeroCompareInDoWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/zeroCompareInDoWhile.kt new file mode 100644 index 00000000000..87ed5964c81 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/zeroCompareInDoWhile.kt @@ -0,0 +1,39 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IFEQ + do { + "loop" + } while (a == 0) + + // Generates IFGT + do { + "loop" + } while (a > 0) + + // Generates IFGE + do { + "loop" + } while (a >= 0) + + // Generates IFLT + do { + "loop" + } while (a < 0) + + // Generates IFLE + do { + "loop" + } while (a <= 0) +} + +//0 ICONST_0 +//1 ICONST_1 +//1 IFEQ +//1 IFLE +//1 IFLT +//1 IFGE +//1 IFGT +//5 IF +//0 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/zeroCompareInIf.kt b/compiler/testData/codegen/bytecodeText/conditions/zeroCompareInIf.kt new file mode 100644 index 00000000000..ea8e88b6dec --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/zeroCompareInIf.kt @@ -0,0 +1,49 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IFNE and GOTO + if (a == 0) { + "then" + } else { + "else" + } + + // Generates IFLE and GOTO + if (a > 0) { + "then" + } else { + "else" + } + + // Generates IFLT and GOTO + if (a >= 0) { + "then" + } else { + "else" + } + + // Generates IFGE and GOTO + if (a < 0) { + "then" + } else { + "else" + } + + // Generates IFGT and GOTO + if (a <= 0) { + "then" + } else { + "else" + } +} + +//0 ICONST_0 +//1 ICONST_1 +//1 IFNE +//1 IFLE +//1 IFLT +//1 IFGE +//1 IFGT +//5 IF +//5 GOTO \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/conditions/zeroCompareInWhile.kt b/compiler/testData/codegen/bytecodeText/conditions/zeroCompareInWhile.kt new file mode 100644 index 00000000000..cc353d0e12f --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/conditions/zeroCompareInWhile.kt @@ -0,0 +1,39 @@ +// Generates ICONST_1 +val a = 1 + +fun main() { + // Generates IFNE and GOTO + while (a == 0) { + "loop" + } + + // Generates IFLE and GOTO + while (a > 0) { + "loop" + } + + // Generates IFLT and GOTO + while (a >= 0) { + "loop" + } + + // Generates IFGE and GOTO + while (a < 0) { + "loop" + } + + // Generates IFGT and GOTO + while (a <= 0) { + "loop" + } +} + +//0 ICONST_0 +//1 ICONST_1 +//1 IFNE +//1 IFLE +//1 IFLT +//1 IFGE +//1 IFGT +//5 IF +//5 GOTO \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index e6de0a9e09b..7c8ea9ed05d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -914,19 +914,49 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/conditions/negatedDisjunction.kt"); } - @TestMetadata("negatedNonZeroCompare.kt") - public void testNegatedNonZeroCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompare.kt"); + @TestMetadata("negatedNonZeroCompareInDoWhile.kt") + public void testNegatedNonZeroCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInDoWhile.kt"); } - @TestMetadata("negatedNullCompare.kt") - public void testNegatedNullCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNullCompare.kt"); + @TestMetadata("negatedNonZeroCompareInIf.kt") + public void testNegatedNonZeroCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInIf.kt"); } - @TestMetadata("negatedZeroCompare.kt") - public void testNegatedZeroCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompare.kt"); + @TestMetadata("negatedNonZeroCompareInWhile.kt") + public void testNegatedNonZeroCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInWhile.kt"); + } + + @TestMetadata("negatedNullCompareInDoWhile.kt") + public void testNegatedNullCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInDoWhile.kt"); + } + + @TestMetadata("negatedNullCompareInIf.kt") + public void testNegatedNullCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInIf.kt"); + } + + @TestMetadata("negatedNullCompareInWhile.kt") + public void testNegatedNullCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInWhile.kt"); + } + + @TestMetadata("negatedZeroCompareInDoWhile.kt") + public void testNegatedZeroCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInDoWhile.kt"); + } + + @TestMetadata("negatedZeroCompareInIf.kt") + public void testNegatedZeroCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInIf.kt"); + } + + @TestMetadata("negatedZeroCompareInWhile.kt") + public void testNegatedZeroCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInWhile.kt"); } @TestMetadata("noBoxingForBoxedEqPrimitive.kt") @@ -944,19 +974,49 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqObject.kt"); } - @TestMetadata("nonZeroCompare.kt") - public void testNonZeroCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/nonZeroCompare.kt"); + @TestMetadata("nonZeroCompareInDoWhile.kt") + public void testNonZeroCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInDoWhile.kt"); } - @TestMetadata("nullCompare.kt") - public void testNullCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/nullCompare.kt"); + @TestMetadata("nonZeroCompareInIf.kt") + public void testNonZeroCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInIf.kt"); } - @TestMetadata("zeroCompare.kt") - public void testZeroCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/zeroCompare.kt"); + @TestMetadata("nonZeroCompareInWhile.kt") + public void testNonZeroCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInWhile.kt"); + } + + @TestMetadata("nullCompareInDoWhile.kt") + public void testNullCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nullCompareInDoWhile.kt"); + } + + @TestMetadata("nullCompareInIf.kt") + public void testNullCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nullCompareInIf.kt"); + } + + @TestMetadata("nullCompareInWhile.kt") + public void testNullCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nullCompareInWhile.kt"); + } + + @TestMetadata("zeroCompareInDoWhile.kt") + public void testZeroCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/zeroCompareInDoWhile.kt"); + } + + @TestMetadata("zeroCompareInIf.kt") + public void testZeroCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/zeroCompareInIf.kt"); + } + + @TestMetadata("zeroCompareInWhile.kt") + public void testZeroCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/zeroCompareInWhile.kt"); } } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java index 1b5302ffac8..34d7b550755 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java @@ -914,19 +914,49 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/conditions/negatedDisjunction.kt"); } - @TestMetadata("negatedNonZeroCompare.kt") - public void testNegatedNonZeroCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompare.kt"); + @TestMetadata("negatedNonZeroCompareInDoWhile.kt") + public void testNegatedNonZeroCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInDoWhile.kt"); } - @TestMetadata("negatedNullCompare.kt") - public void testNegatedNullCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNullCompare.kt"); + @TestMetadata("negatedNonZeroCompareInIf.kt") + public void testNegatedNonZeroCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInIf.kt"); } - @TestMetadata("negatedZeroCompare.kt") - public void testNegatedZeroCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompare.kt"); + @TestMetadata("negatedNonZeroCompareInWhile.kt") + public void testNegatedNonZeroCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNonZeroCompareInWhile.kt"); + } + + @TestMetadata("negatedNullCompareInDoWhile.kt") + public void testNegatedNullCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInDoWhile.kt"); + } + + @TestMetadata("negatedNullCompareInIf.kt") + public void testNegatedNullCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInIf.kt"); + } + + @TestMetadata("negatedNullCompareInWhile.kt") + public void testNegatedNullCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedNullCompareInWhile.kt"); + } + + @TestMetadata("negatedZeroCompareInDoWhile.kt") + public void testNegatedZeroCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInDoWhile.kt"); + } + + @TestMetadata("negatedZeroCompareInIf.kt") + public void testNegatedZeroCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInIf.kt"); + } + + @TestMetadata("negatedZeroCompareInWhile.kt") + public void testNegatedZeroCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/negatedZeroCompareInWhile.kt"); } @TestMetadata("noBoxingForBoxedEqPrimitive.kt") @@ -944,19 +974,49 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/conditions/noBoxingForPrimitiveEqObject.kt"); } - @TestMetadata("nonZeroCompare.kt") - public void testNonZeroCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/nonZeroCompare.kt"); + @TestMetadata("nonZeroCompareInDoWhile.kt") + public void testNonZeroCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInDoWhile.kt"); } - @TestMetadata("nullCompare.kt") - public void testNullCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/nullCompare.kt"); + @TestMetadata("nonZeroCompareInIf.kt") + public void testNonZeroCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInIf.kt"); } - @TestMetadata("zeroCompare.kt") - public void testZeroCompare() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/conditions/zeroCompare.kt"); + @TestMetadata("nonZeroCompareInWhile.kt") + public void testNonZeroCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nonZeroCompareInWhile.kt"); + } + + @TestMetadata("nullCompareInDoWhile.kt") + public void testNullCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nullCompareInDoWhile.kt"); + } + + @TestMetadata("nullCompareInIf.kt") + public void testNullCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nullCompareInIf.kt"); + } + + @TestMetadata("nullCompareInWhile.kt") + public void testNullCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/nullCompareInWhile.kt"); + } + + @TestMetadata("zeroCompareInDoWhile.kt") + public void testZeroCompareInDoWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/zeroCompareInDoWhile.kt"); + } + + @TestMetadata("zeroCompareInIf.kt") + public void testZeroCompareInIf() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/zeroCompareInIf.kt"); + } + + @TestMetadata("zeroCompareInWhile.kt") + public void testZeroCompareInWhile() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/conditions/zeroCompareInWhile.kt"); } }