-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[JIT] - Fixed sub-optimal optimization for a % 1 to Zero
#77760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
20f9bd0
b16ce6f
71c19d1
ad1fab7
daaa0c4
79aff96
3428879
46413df
a6af61e
ea19049
9c1d679
8b11f51
c757925
87fdc1d
60835fd
05086f9
84f12f4
41f3a56
4b8bccc
eb6f860
6504bcd
7bc349d
0c225ee
475e4d6
2c37388
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // 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; | ||
|
|
||
| namespace CodeGenTests | ||
| { | ||
| static class IntRemainder | ||
| { | ||
| static int _fieldValue = 123; | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static int Int32_RemainderByOne() | ||
| { | ||
| // X64-FULL-LINE: call CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE | ||
| // X64-FULL-LINE-NEXT: xor [[REG0:[a-z]+]], [[REG0]] | ||
|
|
||
| // ARM64-FULL-LINE: bl CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE | ||
| // ARM64-FULL-LINE-NEXT: mov [[REG0:[a-z0-9]+]], wzr | ||
|
|
||
| return _fieldValue % 1; | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static int Int32_RemainderByOneWithValue(int value) | ||
| { | ||
| // X64-FULL-LINE: xor [[REG0:[a-z]+]], [[REG0]] | ||
|
|
||
| // ARM64-FULL-LINE: mov [[REG0:[a-z0-9]+]], wzr | ||
|
|
||
| return value % 1; | ||
| } | ||
|
|
||
| static int Main() | ||
| { | ||
| if (Int32_RemainderByOne() != 0) | ||
| return 0; | ||
|
|
||
| if (Int32_RemainderByOneWithValue(-123) != 0) | ||
| return 0; | ||
|
|
||
| return 100; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <DebugType>None</DebugType> | ||
| <Optimize>True</Optimize> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="$(MSBuildProjectName).cs"> | ||
| <HasDisasmCheck>true</HasDisasmCheck> | ||
| </Compile> | ||
|
|
||
| <CLRTestEnvironmentVariable Include="DOTNET_TieredCompilation" Value="0" /> | ||
| <CLRTestEnvironmentVariable Include="DOTNET_JITMinOpts" Value="0" /> | ||
|
Comment on lines
+14
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing I don't remember: If we have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </ItemGroup> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| public class Program | ||
| { | ||
| public static ulong[,] s_1; | ||
| public static int Main() | ||
| { | ||
| // This should not assert. | ||
| try | ||
| { | ||
| ushort vr10 = default(ushort); | ||
| bool vr11 = 0 < ((s_1[0, 0] * (uint)(0 / vr10)) % 1); | ||
| } | ||
| catch {} | ||
|
|
||
| return 100; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <DebugType>None</DebugType> | ||
| <Optimize>True</Optimize> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="$(MSBuildProjectName).cs" /> | ||
| </ItemGroup> | ||
| </Project> |
Uh oh!
There was an error while loading. Please reload this page.