Skip to content

Commit f1045bd

Browse files
committed
Fix recursive [Intrinsic]
1 parent 9b40636 commit f1045bd

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/coreclr/jit/importercalls.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -2863,7 +2863,17 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
28632863
if (isIntrinsic)
28642864
{
28652865
// The recursive non-virtual calls to Jit intrinsics are must-expand by convention.
2866-
mustExpand = gtIsRecursiveCall(method) && !(methodFlags & CORINFO_FLG_VIRTUAL);
2866+
if ((ni > NI_HW_INTRINSIC_START) && (ni < NI_SIMD_AS_HWINTRINSIC_END))
2867+
{
2868+
// Keep the previous logic for HW intrinsics. Some of the recursive calls with [Intrinsic]
2869+
// don't have to be expanded in JIT (e.g. various imm-able intrinsics where the imm-argument is not
2870+
// a constant). To remove this quirk, we need to slightly refactor the mustExpand logic for HWIntrinsics.
2871+
mustExpand = gtIsRecursiveCall(method) && !(methodFlags & CORINFO_FLG_VIRTUAL);
2872+
}
2873+
else
2874+
{
2875+
mustExpand = (info.compMethodHnd == method) && !(methodFlags & CORINFO_FLG_VIRTUAL);
2876+
}
28672877
}
28682878
else
28692879
{

src/libraries/System.Private.CoreLib/src/System/Type.cs

-8
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,12 @@ public virtual Type[] GetGenericParameterConstraints()
127127
protected virtual bool IsMarshalByRefImpl() => false;
128128
public bool IsPrimitive
129129
{
130-
#if NATIVEAOT
131-
// https://github.com/dotnet/runtime/issues/97272
132-
[MethodImpl(MethodImplOptions.NoOptimization)]
133-
#endif
134130
[Intrinsic]
135131
get => IsPrimitiveImpl();
136132
}
137133
protected abstract bool IsPrimitiveImpl();
138134
public bool IsValueType
139135
{
140-
#if NATIVEAOT
141-
// https://github.com/dotnet/runtime/issues/97272
142-
[MethodImpl(MethodImplOptions.NoOptimization)]
143-
#endif
144136
[Intrinsic]
145137
get => IsValueTypeImpl();
146138
}

0 commit comments

Comments
 (0)