diff --git a/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode.kt b/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode.kt deleted file mode 100644 index a235c1e3e22..00000000000 --- a/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode.kt +++ /dev/null @@ -1,17 +0,0 @@ -// IGNORE_BACKEND: JVM_IR -// TODO KT-36846 Generate TABLESWITCH/LOOKUPSWITCH in case of matching hashCodes in JVM_IR - -fun foo(x : String) : String { - assert("abz]".hashCode() == "aby|".hashCode()) - - when (x) { - "abz]" -> return "abz" - "ghi" -> return "ghi" - "aby|" -> return "aby" - "abz]" -> return "fail" - } - - return "other" -} - -// 1 LOOKUPSWITCH diff --git a/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode2.kt b/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCodeFewBranches.kt similarity index 77% rename from compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode2.kt rename to compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCodeFewBranches.kt index 147fea74443..5c6d7a24e61 100644 --- a/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode2.kt +++ b/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCodeFewBranches.kt @@ -1,6 +1,3 @@ -// IGNORE_BACKEND: JVM -import kotlin.test.assertEquals - fun foo(x : String) : String { assert("abz]".hashCode() == "aby|".hashCode()) @@ -14,6 +11,9 @@ fun foo(x : String) : String { return "other" } -// Expecting 0 LOOKUPSWITCH as there is only 2 different hash codes. -// An IF casecade is more efficient. +// JVM_TEMPLATES: +// 1 LOOKUPSWITCH + +// JVM_IR_TEMPLATES: +// Expecting 0 LOOKUPSWITCH as there is only 2 different hash codes. An IF cascade is more efficient. // 0 LOOKUPSWITCH diff --git a/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode3.kt b/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCodeMoreBranches.kt similarity index 93% rename from compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode3.kt rename to compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCodeMoreBranches.kt index f2800eab8b5..44958966402 100644 --- a/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode3.kt +++ b/compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCodeMoreBranches.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM import kotlin.test.assertEquals fun foo(x : String) : String { @@ -16,4 +15,6 @@ fun foo(x : String) : String { } // 1 LOOKUPSWITCH + +// JVM_IR_TEMPLATES: // 0 LDC "fail" diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index e57e7c59e3a..b832243ea32 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -4931,19 +4931,14 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItems.kt"); } - @TestMetadata("duplicatingItemsSameHashCode.kt") - public void testDuplicatingItemsSameHashCode() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode.kt"); + @TestMetadata("duplicatingItemsSameHashCodeFewBranches.kt") + public void testDuplicatingItemsSameHashCodeFewBranches() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCodeFewBranches.kt"); } - @TestMetadata("duplicatingItemsSameHashCode2.kt") - public void testDuplicatingItemsSameHashCode2() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode2.kt"); - } - - @TestMetadata("duplicatingItemsSameHashCode3.kt") - public void testDuplicatingItemsSameHashCode3() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode3.kt"); + @TestMetadata("duplicatingItemsSameHashCodeMoreBranches.kt") + public void testDuplicatingItemsSameHashCodeMoreBranches() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCodeMoreBranches.kt"); } @TestMetadata("expression.kt") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java index 91733f5f01c..239929bd763 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java @@ -4899,19 +4899,14 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItems.kt"); } - @TestMetadata("duplicatingItemsSameHashCode.kt") - public void testDuplicatingItemsSameHashCode() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode.kt"); + @TestMetadata("duplicatingItemsSameHashCodeFewBranches.kt") + public void testDuplicatingItemsSameHashCodeFewBranches() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCodeFewBranches.kt"); } - @TestMetadata("duplicatingItemsSameHashCode2.kt") - public void testDuplicatingItemsSameHashCode2() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode2.kt"); - } - - @TestMetadata("duplicatingItemsSameHashCode3.kt") - public void testDuplicatingItemsSameHashCode3() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCode3.kt"); + @TestMetadata("duplicatingItemsSameHashCodeMoreBranches.kt") + public void testDuplicatingItemsSameHashCodeMoreBranches() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/whenStringOptimization/duplicatingItemsSameHashCodeMoreBranches.kt"); } @TestMetadata("expression.kt")