-
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.
Account for HWI stores in LIR side effects code (#65079)
* Add a test * Account for HWI stores in LIR side effect code Otherwise we risk missing stores to addressable locations. * Add MEMORYBARRIER to fix the assert Won't ever matter as memory barriers split statements.
- Loading branch information
1 parent
30abc7b
commit 99452b2
Showing
3 changed files
with
57 additions
and
1 deletion.
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
37 changes: 37 additions & 0 deletions
37
src/tests/JIT/HardwareIntrinsics/General/HwiOp/HwiSideEffects.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,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Runtime.Intrinsics.X86; | ||
using System.Runtime.CompilerServices; | ||
|
||
// Tests that side effects induced by the HWI nodes are correctly accounted for. | ||
|
||
unsafe class HwiSideEffects | ||
{ | ||
public static int Main() | ||
{ | ||
if (ProblemWithInterferenceChecks(2) != 2) | ||
{ | ||
return 101; | ||
} | ||
|
||
return 100; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static uint ProblemWithInterferenceChecks(uint a) | ||
{ | ||
uint x; | ||
if (Bmi2.IsSupported) | ||
{ | ||
// Make sure we don't try to contain "a" under the "add" here. | ||
x = a + Bmi2.MultiplyNoFlags(a, a, &a); | ||
} | ||
else | ||
{ | ||
x = a; | ||
} | ||
|
||
return x; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/tests/JIT/HardwareIntrinsics/General/HwiOp/HwiSideEffects.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,11 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<DebugType>None</DebugType> | ||
<Optimize>True</Optimize> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |