JVM: KT-40664 disable optimization for 'ULong in range of UInt' case
This commit is contained in:
+4
-4
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.codegen.range.inExpression.InExpressionGenerator
|
|||||||
import org.jetbrains.kotlin.codegen.range.inExpression.InFloatingPointRangeLiteralExpressionGenerator
|
import org.jetbrains.kotlin.codegen.range.inExpression.InFloatingPointRangeLiteralExpressionGenerator
|
||||||
import org.jetbrains.kotlin.codegen.range.inExpression.InIntegralContinuousRangeExpressionGenerator
|
import org.jetbrains.kotlin.codegen.range.inExpression.InIntegralContinuousRangeExpressionGenerator
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.isTopLevelInPackage
|
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
import org.jetbrains.kotlin.psi.KtForExpression
|
import org.jetbrains.kotlin.psi.KtForExpression
|
||||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||||
@@ -70,9 +69,10 @@ abstract class PrimitiveNumberRangeIntrinsicRangeValue(
|
|||||||
?: throw AssertionError("Floating point intrinsic range value should be a range literal")
|
?: throw AssertionError("Floating point intrinsic range value should be a range literal")
|
||||||
InFloatingPointRangeLiteralExpressionGenerator(operatorReference, rangeLiteral, comparisonGenerator, codegen.frameMap)
|
InFloatingPointRangeLiteralExpressionGenerator(operatorReference, rangeLiteral, comparisonGenerator, codegen.frameMap)
|
||||||
}
|
}
|
||||||
else -> InIntegralContinuousRangeExpressionGenerator(
|
else ->
|
||||||
operatorReference, rangeContainsTypeInfo, getBoundedValue(codegen), comparisonGenerator, codegen.frameMap
|
InIntegralContinuousRangeExpressionGenerator(
|
||||||
)
|
operatorReference, rangeContainsTypeInfo, getBoundedValue(codegen), comparisonGenerator, codegen.frameMap
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -87,7 +87,10 @@ fun getComparisonGeneratorForRangeContainsCall(
|
|||||||
getComparisonGeneratorForKotlinType(elementType)
|
getComparisonGeneratorForKotlinType(elementType)
|
||||||
|
|
||||||
KotlinBuiltIns.isUInt(elementType) ->
|
KotlinBuiltIns.isUInt(elementType) ->
|
||||||
UIntComparisonGenerator
|
if (KotlinBuiltIns.isULong(valueParameterType))
|
||||||
|
null
|
||||||
|
else
|
||||||
|
UIntComparisonGenerator
|
||||||
|
|
||||||
KotlinBuiltIns.isULong(elementType) ->
|
KotlinBuiltIns.isULong(elementType) ->
|
||||||
ULongComparisonGenerator
|
ULongComparisonGenerator
|
||||||
|
|||||||
Generated
+5
@@ -24361,6 +24361,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outOfBoundsInMixedContains.kt")
|
||||||
|
public void testOutOfBoundsInMixedContains() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/outOfBoundsInMixedContains.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// KJS_WITH_FULL_RUNTIME
|
||||||
|
|
||||||
|
fun testIn(x: ULong) =
|
||||||
|
x in UInt.MIN_VALUE..UInt.MAX_VALUE
|
||||||
|
|
||||||
|
fun box(): String =
|
||||||
|
if (testIn(UInt.MAX_VALUE.toULong() + 1UL))
|
||||||
|
"Failed"
|
||||||
|
else
|
||||||
|
"OK"
|
||||||
@@ -16,9 +16,9 @@ fun ui_us(x: UInt, a: UShort, b: UShort) = x in a..b
|
|||||||
fun ui_ui(x: UInt, a: UInt, b: UInt) = x in a..b
|
fun ui_ui(x: UInt, a: UInt, b: UInt) = x in a..b
|
||||||
fun ui_ul(x: UInt, a: ULong, b: ULong) = x in a..b
|
fun ui_ul(x: UInt, a: ULong, b: ULong) = x in a..b
|
||||||
|
|
||||||
fun ul_ub(x: ULong, a: UByte, b: UByte) = x in a..b
|
fun ul_ub(x: ULong, a: UByte, b: UByte) = x in a..b // ULong in range of UInt, uses non-intrinsic 'contains'
|
||||||
fun ul_us(x: ULong, a: UShort, b: UShort) = x in a..b
|
fun ul_us(x: ULong, a: UShort, b: UShort) = x in a..b // ULong in range of UInt, uses non-intrinsic 'contains'
|
||||||
fun ul_ui(x: ULong, a: UInt, b: UInt) = x in a..b
|
fun ul_ui(x: ULong, a: UInt, b: UInt) = x in a..b // ULong in range of UInt, uses non-intrinsic 'contains'
|
||||||
fun ul_ul(x: ULong, a: ULong, b: ULong) = x in a..b
|
fun ul_ul(x: ULong, a: ULong, b: ULong) = x in a..b
|
||||||
|
|
||||||
fun n_ub_ub(x: UByte, a: UByte, b: UByte) = x !in a..b
|
fun n_ub_ub(x: UByte, a: UByte, b: UByte) = x !in a..b
|
||||||
@@ -36,17 +36,17 @@ fun n_ui_us(x: UInt, a: UShort, b: UShort) = x !in a..b
|
|||||||
fun n_ui_ui(x: UInt, a: UInt, b: UInt) = x !in a..b
|
fun n_ui_ui(x: UInt, a: UInt, b: UInt) = x !in a..b
|
||||||
fun n_ui_ul(x: UInt, a: ULong, b: ULong) = x !in a..b
|
fun n_ui_ul(x: UInt, a: ULong, b: ULong) = x !in a..b
|
||||||
|
|
||||||
fun n_ul_ub(x: ULong, a: UByte, b: UByte) = x !in a..b
|
fun n_ul_ub(x: ULong, a: UByte, b: UByte) = x !in a..b // ULong in range of UInt, uses non-intrinsic 'contains'
|
||||||
fun n_ul_us(x: ULong, a: UShort, b: UShort) = x !in a..b
|
fun n_ul_us(x: ULong, a: UShort, b: UShort) = x !in a..b // ULong in range of UInt, uses non-intrinsic 'contains'
|
||||||
fun n_ul_ui(x: ULong, a: UInt, b: UInt) = x !in a..b
|
fun n_ul_ui(x: ULong, a: UInt, b: UInt) = x !in a..b // ULong in range of UInt, uses non-intrinsic 'contains'
|
||||||
fun n_ul_ul(x: ULong, a: ULong, b: ULong) = x !in a..b
|
fun n_ul_ul(x: ULong, a: ULong, b: ULong) = x !in a..b
|
||||||
|
|
||||||
// 0 contains
|
// 6 contains
|
||||||
// 16 IFLE
|
// 13 IFLE
|
||||||
// 16 IFLT
|
// 13 IFLT
|
||||||
// 16 IFGE
|
// 13 IFGE
|
||||||
// 16 IFGT
|
// 13 IFGT
|
||||||
// 6 L2I
|
// 0 L2I
|
||||||
// 22 SIPUSH 255
|
// 22 SIPUSH 255
|
||||||
// 24 LDC 65535
|
// 24 LDC 65535
|
||||||
// 2 LDC 4294967295
|
// 2 LDC 4294967295
|
||||||
|
|||||||
+5
@@ -25957,6 +25957,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outOfBoundsInMixedContains.kt")
|
||||||
|
public void testOutOfBoundsInMixedContains() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/outOfBoundsInMixedContains.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+5
@@ -23591,6 +23591,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outOfBoundsInMixedContains.kt")
|
||||||
|
public void testOutOfBoundsInMixedContains() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/outOfBoundsInMixedContains.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+5
@@ -24361,6 +24361,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outOfBoundsInMixedContains.kt")
|
||||||
|
public void testOutOfBoundsInMixedContains() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/outOfBoundsInMixedContains.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Generated
+5
@@ -20727,6 +20727,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outOfBoundsInMixedContains.kt")
|
||||||
|
public void testOutOfBoundsInMixedContains() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/outOfBoundsInMixedContains.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Generated
+5
@@ -20727,6 +20727,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outOfBoundsInMixedContains.kt")
|
||||||
|
public void testOutOfBoundsInMixedContains() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/outOfBoundsInMixedContains.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+5
@@ -20742,6 +20742,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
runTest("compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("outOfBoundsInMixedContains.kt")
|
||||||
|
public void testOutOfBoundsInMixedContains() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/unsigned/outOfBoundsInMixedContains.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
@TestMetadata("compiler/testData/codegen/box/ranges/unsigned/expression")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user