1f4a3b0d1c
comparisons. Having those conversions leads to unnecesary boxing and null checks. This change does it only for JVM in the optimization lowering. It is unclear to me if the other backends can get away with something similar.
34 lines
963 B
Kotlin
Vendored
34 lines
963 B
Kotlin
Vendored
// !LANGUAGE: +ProperIeee754Comparisons
|
|
// IGNORE_BACKEND: JVM_IR
|
|
|
|
fun equals3(a: Short?, b: Short?) = a != null && b != null && a == b
|
|
|
|
fun equals4(a: Short?, b: Short?) = if (a is Short && b is Short) a == b else null!!
|
|
|
|
fun equals5(a: Any?, b: Any?) = if (a is Short && b is Short) a == b else null!!
|
|
|
|
fun less3(a: Short?, b: Short?) = a != null && b != null && a < b
|
|
|
|
fun less4(a: Short?, b: Short?) = if (a is Short && b is Short) a < b else true
|
|
|
|
fun less5(a: Any?, b: Any?) = if (a is Short && b is Short) a < b else true
|
|
|
|
// JVM_TEMPLATES
|
|
// 3 Intrinsics\.areEqual
|
|
// 0 Intrinsics\.compare
|
|
// 4 INVOKEVIRTUAL java/lang/Short\.shortValue \(\)S
|
|
// 2 INVOKEVIRTUAL java/lang/Number\.intValue \(\)I
|
|
// 0 IFGE
|
|
// 3 IF_ICMPGE
|
|
// 0 IF_ICMPNE
|
|
|
|
// JVM_IR_TEMPLATES
|
|
// 2 Intrinsics\.areEqual
|
|
// 0 Intrinsics\.compare
|
|
// 4 INVOKEVIRTUAL java/lang/Short\.shortValue \(\)S
|
|
// 4 INVOKEVIRTUAL java/lang/Number\.shortValue \(\)S
|
|
// 0 IFGE
|
|
// 3 IF_ICMPGE
|
|
// 0 IF_ICMPNE
|
|
|