Minor, refactor bytecode text tests on when-over-string optimization
- Merge `duplicatingItemsSameHashCode.kt` and
`duplicatingItemsSameHashCode2.kt` into one test enabled on both
backends, and rename it to
`duplicatingItemsSameHashCodeFewBranches.kt`.
- Rename `duplicatingItemsSameHashCode3.kt` to
`duplicatingItemsSameHashCodeMoreBranches.kt`, and also enable it for
both backends.
- Use JVM_TEMPLATES/JVM_IR_TEMPLATES to check backend-specific behavior:
1) JVM IR does not optimize less than 2 branches by design
2) JVM IR does not generate duplicate branches, also by design
Related to KT-36846.
This commit is contained in:
Vendored
-17
@@ -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
|
||||
+5
-5
@@ -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
|
||||
+2
-1
@@ -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"
|
||||
Reference in New Issue
Block a user