Skip to content

Commit 5f3e1ff

Browse files
authored
Normalize TYP_STRUCT to TYP_SIMD in impInlineUnboxNullable (#116372)
1 parent d1e2b69 commit 5f3e1ff

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

src/coreclr/jit/importer.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2934,18 +2934,22 @@ GenTree* Compiler::impInlineUnboxNullable(CORINFO_CLASS_HANDLE nullableCls, GenT
29342934
// result._hasValue = true;
29352935
// result._value = MethodTableLookup(obj);
29362936
//
2937-
CORINFO_FIELD_HANDLE valueFldHnd = info.compCompHnd->getFieldInClass(nullableCls, 1);
2938-
CORINFO_CLASS_HANDLE valueStructCls;
2939-
var_types valueType = JITtype2varType(info.compCompHnd->getFieldType(valueFldHnd, &valueStructCls));
2937+
CORINFO_FIELD_HANDLE valueFldHnd = info.compCompHnd->getFieldInClass(nullableCls, 1);
2938+
CORINFO_CLASS_HANDLE valueStructCls = NO_CLASS_HANDLE;
2939+
ClassLayout* layout = nullptr;
2940+
2941+
CorInfoType corFldType = info.compCompHnd->getFieldType(valueFldHnd, &valueStructCls);
2942+
var_types valueType = TypeHandleToVarType(corFldType, valueStructCls, &layout);
2943+
29402944
static_assert_no_msg(OFFSETOF__CORINFO_NullableOfT__hasValue == 0);
29412945
unsigned hasValOffset = OFFSETOF__CORINFO_NullableOfT__hasValue;
29422946
unsigned valueOffset = info.compCompHnd->getFieldOffset(valueFldHnd);
29432947

29442948
GenTree* boxedContentAddr =
29452949
gtNewOperNode(GT_ADD, TYP_BYREF, gtCloneExpr(objClone), gtNewIconNode(TARGET_POINTER_SIZE, TYP_I_IMPL));
29462950
// Load the boxed content from the object (op1):
2947-
GenTree* boxedContent = valueType == TYP_STRUCT ? gtNewBlkIndir(typGetObjLayout(valueStructCls), boxedContentAddr)
2948-
: gtNewIndir(valueType, boxedContentAddr);
2951+
GenTree* boxedContent = gtNewLoadValueNode(valueType, layout, boxedContentAddr);
2952+
29492953
// Now do two stores via a comma:
29502954
GenTree* setHasValue = gtNewStoreLclFldNode(resultTmp, TYP_UBYTE, hasValOffset, gtNewIconNode(1));
29512955
GenTree* setValue = gtNewStoreLclFldNode(resultTmp, valueType, valueOffset, boxedContent);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
// Generated by Fuzzlyn v3.3 on 2025-06-06 10:21:46
5+
// Run on X64 Windows
6+
// Seed: 1256851873714619775-async,vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86bmi1,x86bmi1x64,x86bmi2,x86bmi2x64,x86fma,x86lzcnt,x86lzcntx64,x86pclmulqdq,x86pclmulqdqv256,x86popcnt,x86popcntx64,x86sse,x86ssex64,x86sse2,x86sse2x64,x86sse3,x86sse41,x86sse41x64,x86sse42,x86sse42x64,x86ssse3,x86x86base
7+
// Reduced from 14.5 KiB to 0.3 KiB in 00:00:21
8+
// Hits JIT assert for Release:
9+
// Assertion failed 'layout->GetType() == TYP_STRUCT' in 'System.Threading.AsyncLocal`1[System.Nullable`1[System.Runtime.Intrinsics.Vector128`1[int]]]:get_Value():System.Nullable`1[System.Runtime.Intrinsics.Vector128`1[int]]:this' during 'Importation' (IL size 44; hash 0x78887c0d; FullOpts)
10+
//
11+
// File: C:\dev\dotnet\runtime3\src\coreclr\jit\gentree.cpp Line: 8641
12+
//
13+
14+
using System;
15+
using System.Threading;
16+
using System.Runtime.Intrinsics;
17+
using Xunit;
18+
19+
public class Runtime_115815
20+
{
21+
public static AsyncLocal<Vector128<int>?> s_asyncLocal7 = new AsyncLocal<Vector128<int>?>();
22+
23+
[Fact]
24+
public static void TestEntryPoint()
25+
{
26+
Vector128<int> vr0 = s_asyncLocal7.Value ??= Vector128.Create<int>(0);
27+
}
28+
}
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)