Skip to content

Commit 0f0981f

Browse files
authored
Fix must-expand intrinsic detection (#99818)
1 parent b1f63db commit 0f0981f

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

src/coreclr/jit/compiler.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -3625,14 +3625,18 @@ class Compiler
36253625

36263626
// Return true if call is a recursive call; return false otherwise.
36273627
// Note when inlining, this looks for calls back to the root method.
3628-
bool gtIsRecursiveCall(GenTreeCall* call)
3628+
bool gtIsRecursiveCall(GenTreeCall* call, bool useInlineRoot = true)
36293629
{
3630-
return gtIsRecursiveCall(call->gtCallMethHnd);
3630+
return gtIsRecursiveCall(call->gtCallMethHnd, useInlineRoot);
36313631
}
36323632

3633-
bool gtIsRecursiveCall(CORINFO_METHOD_HANDLE callMethodHandle)
3633+
bool gtIsRecursiveCall(CORINFO_METHOD_HANDLE callMethodHandle, bool useInlineRoot = true)
36343634
{
3635-
return (callMethodHandle == impInlineRoot()->info.compMethodHnd);
3635+
if (useInlineRoot)
3636+
{
3637+
return callMethodHandle == impInlineRoot()->info.compMethodHnd;
3638+
}
3639+
return callMethodHandle == info.compMethodHnd;
36363640
}
36373641

36383642
//-------------------------------------------------------------------------

src/coreclr/jit/hwintrinsic.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ GenTree* Compiler::addRangeCheckIfNeeded(
835835
)
836836
{
837837
assert(!immOp->IsCnsIntOrI());
838-
assert(varTypeIsUnsigned(immOp));
838+
assert(varTypeIsIntegral(immOp));
839839

840840
return addRangeCheckForHWIntrinsic(immOp, immLowerBound, immUpperBound);
841841
}

src/coreclr/jit/importercalls.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2886,7 +2886,7 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
28862886
if (isIntrinsic)
28872887
{
28882888
// The recursive non-virtual calls to Jit intrinsics are must-expand by convention.
2889-
mustExpand = gtIsRecursiveCall(method) && !(methodFlags & CORINFO_FLG_VIRTUAL);
2889+
mustExpand = gtIsRecursiveCall(method, false) && !(methodFlags & CORINFO_FLG_VIRTUAL);
28902890
}
28912891
else
28922892
{
@@ -10135,7 +10135,7 @@ NamedIntrinsic Compiler::lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method)
1013510135
assert(strcmp(className, "Vector`1") == 0);
1013610136
result = NI_Vector_GetCount;
1013710137
}
10138-
else if (gtIsRecursiveCall(method))
10138+
else if (gtIsRecursiveCall(method, false))
1013910139
{
1014010140
// For the framework itself, any recursive intrinsics will either be
1014110141
// only supported on a single platform or will be guarded by a relevant
@@ -10370,7 +10370,7 @@ NamedIntrinsic Compiler::lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method)
1037010370

1037110371
result = NI_Vector_GetCount;
1037210372
}
10373-
else if (gtIsRecursiveCall(method))
10373+
else if (gtIsRecursiveCall(method, false))
1037410374
{
1037510375
// For the framework itself, any recursive intrinsics will either be
1037610376
// only supported on a single platform or will be guarded by a relevant

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)