Skip to content

Commit

Permalink
Fix SIMD12 assert when passing on stack on x64 Unix, arm64 Unix/Windo…
Browse files Browse the repository at this point in the history
…ws. (#49101)

* Fix the assert.

* Add a repro test.

* formatting
  • Loading branch information
Sergey Andreenko committed Mar 4, 2021
1 parent e6fa0f5 commit 1e1b5cf
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,11 @@ GenTree* Lowering::NewPutArg(GenTreeCall* call, GenTree* arg, fgArgTabEntry* inf
#if defined(FEATURE_SIMD) && defined(FEATURE_PUT_STRUCT_ARG_STK)
if (type == TYP_SIMD12)
{
#if !defined(TARGET_64BIT) || defined(OSX_ARM64_ABI)
assert(info->GetByteSize() == 12);
#else // TARGET_64BIT && !OSX_ARM64_ABI
assert(info->GetByteSize() == 16);
#endif // FEATURE_SIMD && FEATURE_PUT_STRUCT_ARG_STK
}
else
#endif // defined(FEATURE_SIMD) && defined(FEATURE_PUT_STRUCT_ARG_STK)
Expand Down
40 changes: 40 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_49101/Runtime_49101.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// 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.CompilerServices;
using System.Numerics;
using System.Diagnostics;

public class Runtime_49101
{
struct S
{
public Vector3 v;
public int anotherField;
}

[MethodImpl(MethodImplOptions.NoInlining)]
static int Test(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, Vector3 v)
{
Debug.Assert(v == Vector3.One);
if (v == Vector3.One)
{
return 100;
}
return 101;
}

[MethodImpl(MethodImplOptions.NoInlining)]
static Vector3 Get()
{
return Vector3.One;
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static int Main()
{
S s;
s.v = Get();
return Test(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, s.v);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit 1e1b5cf

Please sign in to comment.