diff --git a/src/mono/mono/mini/abcremoval.c b/src/mono/mono/mini/abcremoval.c index 44317cdac6c5cb..c758a485a0fcfa 100644 --- a/src/mono/mono/mini/abcremoval.c +++ b/src/mono/mono/mini/abcremoval.c @@ -493,7 +493,7 @@ get_relations_from_previous_bb (MonoVariableRelationsEvaluationArea *area, MonoB symmetric_relation = MONO_SYMMETRIC_RELATION (branch_relation); /* FIXME: Other compare opcodes */ - if (compare->opcode == OP_ICOMPARE) { + if (compare->opcode == OP_ICOMPARE && compare->sreg1 != compare->sreg2) { relations->relation1.variable = compare->sreg1; relations->relation1.relation.relation = branch_relation; relations->relation1.relation.related_value.type = MONO_VARIABLE_SUMMARIZED_VALUE; diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs new file mode 100644 index 00000000000000..21912e06ce8810 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Threading.Tasks; + +public class Test +{ + public int foo; + + public override bool Equals(object o) => false; + public override int GetHashCode() => 0; + + public static bool operator ==(Test t1, Test t2) { + if (ReferenceEquals(t1, t1)) + return true; + return t1.foo == t2.foo; + } + + public static bool operator !=(Test t1, Test t2) { + if (ReferenceEquals(t1, t1)) + return true; + return t1.foo == t2.foo; + } + + public static int Main () { + var t1 = new Test () { foo = 1 }; + var t2 = new Test () { foo = 2 }; + if (t1 == t2) + return 100; + return 100; + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj new file mode 100644 index 00000000000000..4ccbe30ff30925 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_71592/test71592.csproj @@ -0,0 +1,9 @@ + + + Exe + 0 + + + + +