Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating the JIT to recognize and handle Vector64/128/256<T> for nint/nuint #52016

Merged
merged 4 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -8297,6 +8297,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
CORINFO_CLASS_HANDLE Vector64LongHandle;
CORINFO_CLASS_HANDLE Vector64UIntHandle;
CORINFO_CLASS_HANDLE Vector64ULongHandle;
CORINFO_CLASS_HANDLE Vector64NIntHandle;
CORINFO_CLASS_HANDLE Vector64NUIntHandle;
#endif // defined(TARGET_ARM64)
CORINFO_CLASS_HANDLE Vector128FloatHandle;
CORINFO_CLASS_HANDLE Vector128DoubleHandle;
Expand All @@ -8308,6 +8310,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
CORINFO_CLASS_HANDLE Vector128LongHandle;
CORINFO_CLASS_HANDLE Vector128UIntHandle;
CORINFO_CLASS_HANDLE Vector128ULongHandle;
CORINFO_CLASS_HANDLE Vector128NIntHandle;
CORINFO_CLASS_HANDLE Vector128NUIntHandle;
#if defined(TARGET_XARCH)
CORINFO_CLASS_HANDLE Vector256FloatHandle;
CORINFO_CLASS_HANDLE Vector256DoubleHandle;
Expand All @@ -8319,6 +8323,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
CORINFO_CLASS_HANDLE Vector256LongHandle;
CORINFO_CLASS_HANDLE Vector256UIntHandle;
CORINFO_CLASS_HANDLE Vector256ULongHandle;
CORINFO_CLASS_HANDLE Vector256NIntHandle;
CORINFO_CLASS_HANDLE Vector256NUIntHandle;
#endif // defined(TARGET_XARCH)
#endif // FEATURE_HW_INTRINSICS

Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17601,6 +17601,12 @@ GenTree* Compiler::gtGetSIMDZero(var_types simdType, CorInfoType simdBaseJitType
case CORINFO_TYPE_ULONG:
assert(simdHandle == m_simdHandleCache->Vector128ULongHandle);
break;
case CORINFO_TYPE_NATIVEINT:
assert(simdHandle == m_simdHandleCache->Vector128NIntHandle);
AntonLapounov marked this conversation as resolved.
Show resolved Hide resolved
break;
case CORINFO_TYPE_NATIVEUINT:
assert(simdHandle == m_simdHandleCache->Vector128NUIntHandle);
break;
#endif // defined(FEATURE_HW_INTRINSICS)

default:
Expand Down Expand Up @@ -17642,6 +17648,12 @@ GenTree* Compiler::gtGetSIMDZero(var_types simdType, CorInfoType simdBaseJitType
case CORINFO_TYPE_ULONG:
assert(simdHandle == m_simdHandleCache->Vector256ULongHandle);
break;
case CORINFO_TYPE_NATIVEINT:
assert(simdHandle == m_simdHandleCache->Vector256NIntHandle);
break;
case CORINFO_TYPE_NATIVEUINT:
assert(simdHandle == m_simdHandleCache->Vector256NUIntHandle);
break;
default:
break;
}
Expand Down
18 changes: 12 additions & 6 deletions src/coreclr/jit/hwintrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleForHWSIMD(var_types simdType, Co
case CORINFO_TYPE_ULONG:
return m_simdHandleCache->Vector128ULongHandle;
case CORINFO_TYPE_NATIVEINT:
break;
return m_simdHandleCache->Vector128NIntHandle;
case CORINFO_TYPE_NATIVEUINT:
break;
return m_simdHandleCache->Vector128NUIntHandle;
default:
assert(!"Didn't find a class handle for simdType");
}
Expand Down Expand Up @@ -150,9 +150,9 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleForHWSIMD(var_types simdType, Co
case CORINFO_TYPE_ULONG:
return m_simdHandleCache->Vector256ULongHandle;
case CORINFO_TYPE_NATIVEINT:
break;
return m_simdHandleCache->Vector256NIntHandle;
case CORINFO_TYPE_NATIVEUINT:
break;
return m_simdHandleCache->Vector256NUIntHandle;
default:
assert(!"Didn't find a class handle for simdType");
}
Expand Down Expand Up @@ -184,9 +184,9 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleForHWSIMD(var_types simdType, Co
case CORINFO_TYPE_ULONG:
return m_simdHandleCache->Vector64ULongHandle;
case CORINFO_TYPE_NATIVEINT:
break;
return m_simdHandleCache->Vector64NIntHandle;
case CORINFO_TYPE_NATIVEUINT:
break;
return m_simdHandleCache->Vector64NUIntHandle;
default:
assert(!"Didn't find a class handle for simdType");
}
Expand Down Expand Up @@ -666,6 +666,12 @@ static bool isSupportedBaseType(NamedIntrinsic intrinsic, CorInfoType baseJitTyp
return false;
}

if ((baseJitType == CORINFO_TYPE_NATIVEINT) || (baseJitType == CORINFO_TYPE_NATIVEUINT))
{
// We don't want to support the general purpose helpers for nint/nuint until after they go through API review.
return false;
}

var_types baseType = JitType2PreciseVarType(baseJitType);

// We don't actually check the intrinsic outside of the false case as we expect
Expand Down
66 changes: 66 additions & 0 deletions src/coreclr/jit/simd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,18 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH
size = Vector256SizeBytes;
JITDUMP(" Known type Vector256<ulong>\n");
}
else if (typeHnd == m_simdHandleCache->Vector256NIntHandle)
{
simdBaseJitType = CORINFO_TYPE_NATIVEINT;
size = Vector256SizeBytes;
JITDUMP(" Known type Vector256<nint>\n");
}
else if (typeHnd == m_simdHandleCache->Vector256NUIntHandle)
{
simdBaseJitType = CORINFO_TYPE_NATIVEUINT;
size = Vector256SizeBytes;
JITDUMP(" Known type Vector256<nuint>\n");
}
else
#endif // defined(TARGET_XARCH)
if (typeHnd == m_simdHandleCache->Vector128FloatHandle)
Expand Down Expand Up @@ -531,6 +543,18 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH
size = Vector128SizeBytes;
JITDUMP(" Known type Vector128<ulong>\n");
}
else if (typeHnd == m_simdHandleCache->Vector128NIntHandle)
{
simdBaseJitType = CORINFO_TYPE_NATIVEINT;
size = Vector128SizeBytes;
JITDUMP(" Known type Vector256<nint>\n");
tannergooding marked this conversation as resolved.
Show resolved Hide resolved
}
else if (typeHnd == m_simdHandleCache->Vector128NUIntHandle)
{
simdBaseJitType = CORINFO_TYPE_NATIVEUINT;
size = Vector128SizeBytes;
JITDUMP(" Known type Vector128<nuint>\n");
}
else
#if defined(TARGET_ARM64)
if (typeHnd == m_simdHandleCache->Vector64FloatHandle)
Expand Down Expand Up @@ -593,6 +617,18 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH
size = Vector64SizeBytes;
JITDUMP(" Known type Vector64<ulong>\n");
}
else if (typeHnd == m_simdHandleCache->Vector64NIntHandle)
{
simdBaseJitType = CORINFO_TYPE_NATIVEINT;
size = Vector64SizeBytes;
JITDUMP(" Known type Vector64<nint>\n");
}
else if (typeHnd == m_simdHandleCache->Vector64NUIntHandle)
{
simdBaseJitType = CORINFO_TYPE_NATIVEUINT;
size = Vector64SizeBytes;
JITDUMP(" Known type Vector64<nuint>\n");
}
#endif // defined(TARGET_ARM64)

// slow path search
Expand Down Expand Up @@ -665,6 +701,16 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH
simdBaseJitType = CORINFO_TYPE_BYTE;
JITDUMP(" Found type Hardware Intrinsic SIMD Vector256<sbyte>\n");
break;
case CORINFO_TYPE_NATIVEINT:
m_simdHandleCache->Vector256NIntHandle = typeHnd;
simdBaseJitType = CORINFO_TYPE_NATIVEINT;
JITDUMP(" Found type Hardware Intrinsic SIMD Vector256<nint>\n");
break;
case CORINFO_TYPE_NATIVEUINT:
m_simdHandleCache->Vector256ULongHandle = typeHnd;
tannergooding marked this conversation as resolved.
Show resolved Hide resolved
simdBaseJitType = CORINFO_TYPE_NATIVEUINT;
JITDUMP(" Found type Hardware Intrinsic SIMD Vector256<nuint>\n");
break;

default:
JITDUMP(" Unknown Hardware Intrinsic SIMD Type Vector256<T>\n");
Expand Down Expand Up @@ -727,6 +773,16 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH
simdBaseJitType = CORINFO_TYPE_BYTE;
JITDUMP(" Found type Hardware Intrinsic SIMD Vector128<sbyte>\n");
break;
case CORINFO_TYPE_NATIVEINT:
m_simdHandleCache->Vector128NIntHandle = typeHnd;
simdBaseJitType = CORINFO_TYPE_NATIVEINT;
JITDUMP(" Found type Hardware Intrinsic SIMD Vector128<nint>\n");
break;
case CORINFO_TYPE_NATIVEUINT:
m_simdHandleCache->Vector128ULongHandle = typeHnd;
tannergooding marked this conversation as resolved.
Show resolved Hide resolved
simdBaseJitType = CORINFO_TYPE_NATIVEUINT;
JITDUMP(" Found type Hardware Intrinsic SIMD Vector128<nuint>\n");
break;

default:
JITDUMP(" Unknown Hardware Intrinsic SIMD Type Vector128<T>\n");
Expand Down Expand Up @@ -788,6 +844,16 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH
simdBaseJitType = CORINFO_TYPE_BYTE;
JITDUMP(" Found type Hardware Intrinsic SIMD Vector64<sbyte>\n");
break;
case CORINFO_TYPE_NATIVEINT:
m_simdHandleCache->Vector64NIntHandle = typeHnd;
simdBaseJitType = CORINFO_TYPE_NATIVEINT;
JITDUMP(" Found type Hardware Intrinsic SIMD Vector64<nint>\n");
break;
case CORINFO_TYPE_NATIVEUINT:
m_simdHandleCache->Vector64ULongHandle = typeHnd;
tannergooding marked this conversation as resolved.
Show resolved Hide resolved
simdBaseJitType = CORINFO_TYPE_NATIVEUINT;
JITDUMP(" Found type Hardware Intrinsic SIMD Vector64<nuint>\n");
break;

default:
JITDUMP(" Unknown Hardware Intrinsic SIMD Type Vector64<T>\n");
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ public bool IsPrimitiveNumeric
case TypeFlags.UInt32:
case TypeFlags.Int64:
case TypeFlags.UInt64:
case TypeFlags.IntPtr:
case TypeFlags.UIntPtr:
case TypeFlags.Single:
case TypeFlags.Double:
return true;
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4384,6 +4384,12 @@ CorInfoType CEEInfo::getTypeForPrimitiveNumericClass(
case ELEMENT_TYPE_R8:
result = CORINFO_TYPE_DOUBLE;
break;
case ELEMENT_TYPE_I:
result = CORINFO_TYPE_NATIVEINT;
break;
case ELEMENT_TYPE_U:
result = CORINFO_TYPE_NATIVEUINT;
break;

default:
// Error case, we will return CORINFO_TYPE_UNDEF
Expand Down