forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete dead code from and fix
getSIMDStructFromField
(dotnet#71226)
* Clean out dead code from "getSIMDStructFromField" The only pattern possible here is "FIELD(ADDR(LCL_VAR))". * Fix the field type issue * Fix the field offset issue * Add tests
- Loading branch information
1 parent
c9d7854
commit 9a461ad
Showing
3 changed files
with
86 additions
and
66 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
56 changes: 56 additions & 0 deletions
56
src/tests/JIT/Regression/JitBlue/Runtime_71219/Runtime_71219.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,56 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Numerics; | ||
using System.Runtime.Intrinsics; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.CompilerServices; | ||
|
||
public class Runtime_71219 | ||
{ | ||
public static int Main() | ||
{ | ||
Vector4 vtor = new Vector4(1, 2, 3, 4); | ||
|
||
if (ProblemWithNonFloatField(vtor)) | ||
{ | ||
return 101; | ||
} | ||
|
||
if (ProblemWithMisalignedField(vtor.AsVector128().AsInt64())) | ||
{ | ||
return 102; | ||
} | ||
|
||
return 100; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static bool ProblemWithNonFloatField(Vector4 vtor) | ||
{ | ||
vtor += vtor; | ||
return Unsafe.As<Vector4, StructWithIndex>(ref vtor).Value != Unsafe.As<float, int>(ref vtor.Y); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static bool ProblemWithMisalignedField(Vector128<long> vtor) | ||
{ | ||
vtor += vtor; | ||
return | ||
Unsafe.As<Vector128<long>, StructWithLng>(ref vtor).Long != | ||
Unsafe.As<byte, long>(ref Unsafe.Add(ref Unsafe.As<Vector128<long>, byte>(ref vtor), 4)); | ||
} | ||
|
||
struct StructWithIndex | ||
{ | ||
public int Index; | ||
public int Value; | ||
} | ||
|
||
[StructLayout(LayoutKind.Explicit)] | ||
struct StructWithLng | ||
{ | ||
[FieldOffset(4)] | ||
public long Long; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/tests/JIT/Regression/JitBlue/Runtime_71219/Runtime_71219.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,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |