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:
+18
@@ -1478,6 +1478,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableDoublesWithTP.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("eqNullableShortToShort.kt")
|
||||
public void testEqNullableShortToShort() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableShortToShort.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("eqNullableToPrimitiveWithSideEffects.kt")
|
||||
public void testEqNullableToPrimitiveWithSideEffects() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/eqNullableToPrimitiveWithSideEffects.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("intrinsic.kt")
|
||||
public void testIntrinsic() throws Exception {
|
||||
@@ -1543,6 +1555,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
public void testOverflowLong() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/overflowLong.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("primitiveEqualsSafeCall.kt")
|
||||
public void testPrimitiveEqualsSafeCall() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/binaryOp/primitiveEqualsSafeCall.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
Reference in New Issue
Block a user