Skip to content

Commit da4e544

Browse files
authored
JIT: DNER multiregs with SIMD12s (#91674)
Locals with SIMD12 fields will span multiple registers when they end up as multireg returns, so these should always be DNER'd. Fix #91214
1 parent 6d5ea33 commit da4e544

File tree

7 files changed

+74
-4
lines changed

7 files changed

+74
-4
lines changed

src/coreclr/jit/lower.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7506,6 +7506,28 @@ bool Lowering::CheckMultiRegLclVar(GenTreeLclVar* lclNode, int registerCount)
75067506
if (registerCount == varDsc->lvFieldCnt)
75077507
{
75087508
canEnregisterAsMultiReg = true;
7509+
7510+
#ifdef FEATURE_SIMD
7511+
// TYP_SIMD12 breaks the above invariant that "we won't have
7512+
// matching reg and field counts"; for example, consider
7513+
//
7514+
// * STORE_LCL_VAR<struct{Vector3, int}>(CALL)
7515+
// * RETURN(LCL_VAR<struct{Vector3, int}>)
7516+
//
7517+
// These return in two GPR registers, while the fields of the
7518+
// local are stored in SIMD and GPR register, so registerCount
7519+
// == varDsc->lvFieldCnt == 2. But the backend cannot handle
7520+
// this.
7521+
7522+
for (int i = 0; i < varDsc->lvFieldCnt; i++)
7523+
{
7524+
if (comp->lvaGetDesc(varDsc->lvFieldLclStart + i)->TypeGet() == TYP_SIMD12)
7525+
{
7526+
canEnregisterAsMultiReg = false;
7527+
break;
7528+
}
7529+
}
7530+
#endif
75097531
}
75107532
}
75117533
}

src/tests/JIT/Regression/JitBlue/Runtime_91062/Runtime_91062.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Licensed to the .NET Foundation under one or more agreements.
2-
// The .NET Foundation licenses this file to you under the MIT license.aa
2+
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Runtime.CompilerServices;
55
using System.Runtime.Intrinsics;

src/tests/JIT/Regression/JitBlue/Runtime_91170/Runtime_91170.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Licensed to the .NET Foundation under one or more agreements.
2-
// The .NET Foundation licenses this file to you under the MIT license.aa
2+
// The .NET Foundation licenses this file to you under the MIT license.
33

44
// Found by Antigen
55

src/tests/JIT/Regression/JitBlue/Runtime_91174/Runtime_91174.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Licensed to the .NET Foundation under one or more agreements.
2-
// The .NET Foundation licenses this file to you under the MIT license.aa
2+
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
55
using System.Runtime.CompilerServices;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
// Found by Antigen
5+
6+
using System.Runtime.CompilerServices;
7+
using System.Runtime.Intrinsics;
8+
using System.Numerics;
9+
using Xunit;
10+
11+
public class Runtime_91214
12+
{
13+
[Fact]
14+
public static void TestEntryPoint()
15+
{
16+
Method0();
17+
}
18+
19+
struct S
20+
{
21+
public Vector3 v3;
22+
public bool b;
23+
}
24+
25+
[MethodImpl(MethodImplOptions.NoInlining)]
26+
static S Method2()
27+
{
28+
return default;
29+
}
30+
31+
[MethodImpl(MethodImplOptions.NoInlining)]
32+
static void Method0()
33+
{
34+
S s = Method2();
35+
Log(null, s.v3);
36+
}
37+
38+
[MethodImpl(MethodImplOptions.NoInlining)]
39+
static void Log(object a, object b) { }
40+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Optimize>True</Optimize>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="$(MSBuildProjectName).cs" />
7+
</ItemGroup>
8+
</Project>

src/tests/JIT/Regression/JitBlue/Runtime_91335/Runtime_91335.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Licensed to the .NET Foundation under one or more agreements.
2-
// The .NET Foundation licenses this file to you under the MIT license.aa
2+
// The .NET Foundation licenses this file to you under the MIT license.
33

44
// Found by Antigen
55

0 commit comments

Comments
 (0)