JVM_IR: fix primitive comparison optimizations
1. the `primitive == object?.something` fusion should not apply to
`primitive.equals(object?.something)` because it can't;
2. coercions to Int are there for a reason - don't remove them;
3. better optimize `primitive == object?.something` -- the result
should be subject to if-null fusion, so it needs to have a specific
pattern that resembles safe calls.
#KT-47597 Fixed
This commit is contained in:
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+15
@@ -806,6 +806,16 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableDoublesWithTP.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eqNullableShortToShort.kt")
|
||||
public void testEqNullableShortToShort() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableShortToShort.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eqNullableToPrimitiveWithSideEffects.kt")
|
||||
public void testEqNullableToPrimitiveWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableToPrimitiveWithSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intrinsic.kt")
|
||||
public void testIntrinsic() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/intrinsic.kt");
|
||||
@@ -860,6 +870,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
public void testOverflowLong() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/overflowLong.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqualsSafeCall.kt")
|
||||
public void testPrimitiveEqualsSafeCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/primitiveEqualsSafeCall.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/boxingOptimization")
|
||||
|
||||
Generated
+15
@@ -806,6 +806,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableDoublesWithTP.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eqNullableShortToShort.kt")
|
||||
public void testEqNullableShortToShort() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableShortToShort.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eqNullableToPrimitiveWithSideEffects.kt")
|
||||
public void testEqNullableToPrimitiveWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableToPrimitiveWithSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intrinsic.kt")
|
||||
public void testIntrinsic() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/intrinsic.kt");
|
||||
@@ -860,6 +870,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
public void testOverflowLong() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/overflowLong.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqualsSafeCall.kt")
|
||||
public void testPrimitiveEqualsSafeCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/primitiveEqualsSafeCall.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/boxingOptimization")
|
||||
|
||||
Generated
+15
@@ -806,6 +806,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableDoublesWithTP.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eqNullableShortToShort.kt")
|
||||
public void testEqNullableShortToShort() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableShortToShort.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eqNullableToPrimitiveWithSideEffects.kt")
|
||||
public void testEqNullableToPrimitiveWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableToPrimitiveWithSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intrinsic.kt")
|
||||
public void testIntrinsic() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/intrinsic.kt");
|
||||
@@ -860,6 +870,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
public void testOverflowLong() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/overflowLong.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqualsSafeCall.kt")
|
||||
public void testPrimitiveEqualsSafeCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/primitiveEqualsSafeCall.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/boxingOptimization")
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+15
@@ -696,6 +696,16 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableDoublesWithTP.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eqNullableShortToShort.kt")
|
||||
public void testEqNullableShortToShort() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableShortToShort.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("eqNullableToPrimitiveWithSideEffects.kt")
|
||||
public void testEqNullableToPrimitiveWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableToPrimitiveWithSideEffects.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intrinsic.kt")
|
||||
public void testIntrinsic() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/intrinsic.kt");
|
||||
@@ -750,6 +760,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
public void testOverflowLong() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/overflowLong.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveEqualsSafeCall.kt")
|
||||
public void testPrimitiveEqualsSafeCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/primitiveEqualsSafeCall.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/boxingOptimization")
|
||||
|
||||
Reference in New Issue
Block a user