Skip to content

Commit 6d412f4

Browse files
Fix x86 hardware intrinsics (#99894)
1 parent 8b04e76 commit 6d412f4

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/coreclr/tools/Common/Compiler/HardwareIntrinsicHelpers.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,22 @@ public static partial class HardwareIntrinsicHelpers
1616
/// </summary>
1717
public static bool IsHardwareIntrinsic(MethodDesc method)
1818
{
19-
return !string.IsNullOrEmpty(InstructionSetSupport.GetHardwareIntrinsicId(method.Context.Target.Architecture, method.OwningType));
19+
// Matches logic in
20+
// https://github.com/dotnet/runtime/blob/5c40bb5636b939fb548492fdeb9d501b599ac5f5/src/coreclr/vm/methodtablebuilder.cpp#L1491-L1512
21+
TypeDesc owningType = method.OwningType;
22+
if (owningType.IsIntrinsic && !owningType.HasInstantiation)
23+
{
24+
var owningMdType = (MetadataType)owningType;
25+
string ns = owningMdType.ContainingType?.Namespace ?? owningMdType.Namespace;
26+
return method.Context.Target.Architecture switch
27+
{
28+
TargetArchitecture.ARM64 => ns == "System.Runtime.Intrinsics.Arm",
29+
TargetArchitecture.X64 or TargetArchitecture.X86 => ns == "System.Runtime.Intrinsics.X86",
30+
_ => false,
31+
};
32+
}
33+
34+
return false;
2035
}
2136

2237
public static void AddRuntimeRequiredIsaFlagsToBuilder(InstructionSetSupportBuilder builder, int flags)

src/coreclr/tools/Common/Compiler/InstructionSetSupport.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ public static string GetHardwareIntrinsicId(TargetArchitecture architecture, Typ
8080
}
8181
else if (architecture == TargetArchitecture.X86)
8282
{
83-
if (potentialType.Name == "X64")
84-
potentialType = (MetadataType)potentialType.ContainingType;
8583
if (potentialType.Name == "VL")
8684
potentialType = (MetadataType)potentialType.ContainingType;
8785
if (potentialType.Namespace != "System.Runtime.Intrinsics.X86")

0 commit comments

Comments
 (0)