diff --git a/src/coreclr/jit/assertionprop.cpp b/src/coreclr/jit/assertionprop.cpp index 28f88eb2d67389..c4d832dd39d57f 100644 --- a/src/coreclr/jit/assertionprop.cpp +++ b/src/coreclr/jit/assertionprop.cpp @@ -5776,6 +5776,8 @@ bool Compiler::optCreateJumpTableImpliedAssertions(BasicBlock* switchBb) void Compiler::optImpliedByTypeOfAssertions(ASSERT_TP& activeAssertions) { + assert(!optLocalAssertionProp); + if (BitVecOps::IsEmpty(apTraits, activeAssertions)) { return; @@ -5804,31 +5806,25 @@ void Compiler::optImpliedByTypeOfAssertions(ASSERT_TP& activeAssertions) { AssertionDsc* impAssertion = optGetAssertion(impIndex); - // The impAssertion must be different from the chkAssertion + // The impAssertion must be different from the chkAssertion if (impIndex == chkAssertionIndex) { continue; } - // impAssertion must be a Non Null assertion on lclNum - if ((impAssertion->assertionKind != OAK_NOT_EQUAL) || (impAssertion->op1.kind != O1K_LCLVAR) || - (impAssertion->op2.kind != O2K_CONST_INT) || (impAssertion->op1.vn != chkAssertion->op1.vn)) + // impAssertion must be a Non Null assertion on op1.vn + if ((impAssertion->assertionKind != OAK_NOT_EQUAL) || !impAssertion->CanPropNonNull() || + (impAssertion->op1.vn != chkAssertion->op1.vn)) { continue; } // The bit may already be in the result set - if (!BitVecOps::IsMember(apTraits, activeAssertions, impIndex - 1)) + if (BitVecOps::TryAddElemD(apTraits, activeAssertions, impIndex - 1)) { - BitVecOps::AddElemD(apTraits, activeAssertions, impIndex - 1); -#ifdef DEBUG - if (verbose) - { - printf("\nCompiler::optImpliedByTypeOfAssertions: %s Assertion #%02d, implies assertion #%02d", - (chkAssertion->op1.kind == O1K_SUBTYPE) ? "Subtype" : "Exact-type", chkAssertionIndex, - impIndex); - } -#endif + JITDUMP("\nCompiler::optImpliedByTypeOfAssertions: %s Assertion #%02d, implies assertion #%02d", + (chkAssertion->op1.kind == O1K_SUBTYPE) ? "Subtype" : "Exact-type", chkAssertionIndex, + impIndex); } // There is at most one non-null assertion that is implied by the current chkIndex assertion diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_120792/Runtime_120792.cs b/src/tests/JIT/Regression/JitBlue/Runtime_120792/Runtime_120792.cs new file mode 100644 index 00000000000000..198d1cd3dd6125 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_120792/Runtime_120792.cs @@ -0,0 +1,28 @@ +// 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.Runtime.CompilerServices; +using System.Threading; +using Xunit; + +public class Runtime_120792 +{ + [Fact] + public static void TestEntryPoint() + { + for (int i = 0; i < 300; i++) + { + Problem(42); + Thread.Sleep(16); + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static void Problem(object value) + { + Type tt = value == null ? typeof(object) : value.GetType(); + if (!tt.Equals(typeof(int)) || value == null) + throw new InvalidOperationException(); + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_120792/Runtime_120792.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_120792/Runtime_120792.csproj new file mode 100644 index 00000000000000..09fb4358127787 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_120792/Runtime_120792.csproj @@ -0,0 +1,13 @@ + + + None + True + + true + + + + + + +