Skip to content

Commit 75c1760

Browse files
authored
JIT: Handle mistyped commas in morph in pre-order too (#91587)
Morph has post-order logic to compensate for mistyped commas produced by impStoreStruct. However, block morphing can optimize unused stores into INDs; this interacts with the mistyped commas to produce illegal IR shapes (e.g. `COMMA<simd12>(..., IND<ubyte>(...))`). The ideal solution is to fix impStoreStruct (#91586 tracks this), but this change has a more surgical fix for the problem that can be backported to .NET 8. Fix #91443
1 parent 54d9fa8 commit 75c1760

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/coreclr/jit/morph.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8909,6 +8909,14 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
89098909
break;
89108910
#endif
89118911

8912+
case GT_COMMA:
8913+
if (op2->OperIsStore() || (op2->OperGet() == GT_COMMA && op2->TypeGet() == TYP_VOID) || fgIsThrow(op2))
8914+
{
8915+
typ = tree->gtType = TYP_VOID;
8916+
}
8917+
8918+
break;
8919+
89128920
default:
89138921
break;
89148922
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
using System.Numerics;
5+
using System.Runtime.CompilerServices;
6+
using Xunit;
7+
8+
public class Runtime_91443
9+
{
10+
[Fact]
11+
public static void TestEntryPoint()
12+
{
13+
new Runtime_91443().Method0();
14+
}
15+
16+
static Vector3 s;
17+
18+
[MethodImpl(MethodImplOptions.NoInlining)]
19+
private void Method0()
20+
{
21+
Vector3.Cross(s, s);
22+
}
23+
}
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>

0 commit comments

Comments
 (0)