-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT: extend RBO partial inference to unsigned relops (#75804)
RBO can now partially infer from a pair of unsigned relops or an unsigned relop and an equality relop. Fixes #65327.
- Loading branch information
1 parent
e8d32c1
commit 78528df
Showing
5 changed files
with
160 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/tests/JIT/opt/RedundantBranch/RedundantBranchUnsigned.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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; | ||
|
||
// Runtime 65327 | ||
// M1 and M2 should generate the same code | ||
|
||
public class RedundantBranchUnsigned | ||
{ | ||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public ReadOnlySpan<char> M1(ReadOnlySpan<char> span, int i) | ||
{ | ||
// Note `<` here instead of `<=` | ||
// | ||
if ((uint)i < (uint)span.Length) | ||
{ | ||
return span.Slice(i); | ||
} | ||
return default; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public ReadOnlySpan<char> M2(ReadOnlySpan<char> span, int i) | ||
{ | ||
if ((uint)i <= (uint)span.Length) | ||
{ | ||
return span.Slice(i); | ||
} | ||
return default; | ||
} | ||
|
||
public static int Main() | ||
{ | ||
var rbu = new RedundantBranchUnsigned(); | ||
var m1 = rbu.M1("hello", 2); | ||
var m2 = rbu.M2("hello", 3); | ||
|
||
return m1.Length + m2.Length + 95; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/tests/JIT/opt/RedundantBranch/RedundantBranchUnsigned.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<DebugType /> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |