Skip to content
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

JIT: Cast UInt64 to Single directly during const folding #106419

Merged
merged 14 commits into from
Aug 20, 2024
13 changes: 10 additions & 3 deletions src/tests/JIT/Regression/JitBlue/Runtime_106338/Runtime_106338.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@
// Debug: Outputs 1600094603
// Release: Outputs 1600094604
using System;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
using Xunit;

public class Runtime_106338
{
[Fact]
public static void TestEntryPoint()
{
ulong vr10 = 16105307123914158031UL;
float vr11 = 4294967295U | vr10;
Assert.Equal(1600094603U, BitConverter.SingleToUInt32Bits(vr11));
bool runTest = (RuntimeInformation.ProcessArchitecture == Architecture.Arm64) || Avx512F.IsSupported;

if (runTest)
{
ulong vr10 = 16105307123914158031UL;
float vr11 = 4294967295U | vr10;
Assert.Equal(1600094603U, BitConverter.SingleToUInt32Bits(vr11));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the test rather assert that its producing 1600094604u if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64) || Avx512F.IsSupported is false?

That way we can detect any changes for other platforms or scenarios?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea; I'll update it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just remembered that we don't build this test if the target arch isn't arm64/x64 (or if the runtime isn't CoreCLR). @tannergooding are you ok with only testing those platforms for now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that’s fine, but ideally we’d ensure this runs everywhere long term

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<Optimize>True</Optimize>
<!-- Needed for CLRTestTargetUnsupported -->
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' != 'arm64' or '$(RuntimeFlavor)' != 'coreclr'">true</CLRTestTargetUnsupported>
<CLRTestTargetUnsupported Condition="'$(TargetArchitecture)' != 'arm64' AND '$(TargetArchitecture)' != 'x64'">true</CLRTestTargetUnsupported>
<CLRTestTargetUnsupported Condition="'$(RuntimeFlavor)' != 'coreclr'">true</CLRTestTargetUnsupported>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only need is we skip this on Mono today, right?
Is that because they're always doing the ulong -> double -> float 2-step behavior?

Can we not instead use [SkipOnMono("https://github.com/dotnet/runtime/issues/#######", TestPlatforms.Any)] and ensure that the test is compiled for all platforms?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Mono seems to also do the two-step cast, so the test was failing across all Mono legs.

Can we not instead use [SkipOnMono("https://github.com/dotnet/runtime/issues/#######", TestPlatforms.Any)] and ensure that the test is compiled for all platforms?

Sure, I'll update it.

</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
Expand Down
Loading