Skip to content

Commit d8e71a4

Browse files
[release/10.0] Ignore re-typed lcl in optAssertionPropLocal_RelOp (#119813)
* Fix optAssertionPropLocal_RelOp for retyped locals * add a test * change comment --------- Co-authored-by: EgorBo <[email protected]>
1 parent d925d45 commit d8e71a4

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

src/coreclr/jit/assertionprop.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4703,6 +4703,13 @@ GenTree* Compiler::optAssertionPropLocal_RelOp(ASSERT_VALARG_TP assertions, GenT
47034703

47044704
// Find an equal or not equal assertion about op1 var.
47054705
unsigned lclNum = op1->AsLclVarCommon()->GetLclNum();
4706+
4707+
// Make sure the local is not truncated.
4708+
if (!op1->TypeIs(lvaGetRealType(lclNum)))
4709+
{
4710+
return nullptr;
4711+
}
4712+
47064713
noway_assert(lclNum < lvaCount);
47074714
AssertionIndex index = optLocalAssertionIsEqualOrNotEqual(op1Kind, lclNum, op2Kind, cnsVal, assertions);
47084715

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Runtime.CompilerServices;
6+
using Xunit;
7+
8+
public class Runtime_119654
9+
{
10+
[Fact]
11+
public static void TestEntryPoint()
12+
{
13+
if (ShouldReturnOne(-4294967296L) != 1)
14+
{
15+
throw new Exception("Test failed");
16+
}
17+
}
18+
19+
[MethodImpl(MethodImplOptions.NoInlining |
20+
MethodImplOptions.AggressiveOptimization)]
21+
private static int ShouldReturnOne(long availableSigned)
22+
{
23+
if (availableSigned == 0L)
24+
return 0;
25+
return (uint)(ulong)availableSigned != 0 ? 111 : 1;
26+
}
27+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<DebugType>None</DebugType>
4+
<Optimize>True</Optimize>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<Compile Include="$(MSBuildProjectName).cs" />
8+
</ItemGroup>
9+
</Project>

0 commit comments

Comments
 (0)