From 114463ca844325c89bd8a8fb38e5def17732dad7 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 13 Jul 2026 22:09:35 +0200 Subject: [PATCH 1/8] Treat Guid as bitwise equatable Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9156991f-d238-4aef-b89d-bdd9ad98ae22 --- src/coreclr/vm/jitinterface.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 75197f0ddd4087..51c399971c55eb 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -7349,6 +7349,7 @@ static bool getILIntrinsicImplementationForRuntimeHelpers( || methodTable == CoreLibBinder::GetClass(CLASS__UINT64) || methodTable == CoreLibBinder::GetClass(CLASS__INTPTR) || methodTable == CoreLibBinder::GetClass(CLASS__UINTPTR) + || methodTable == CoreLibBinder::GetClass(CLASS__GUID) || methodTable == CoreLibBinder::GetClass(CLASS__RUNE) || methodTable->IsEnum() || IsBitwiseEquatable(typeHandle, methodTable)) From 61a8392e77bd77055a3bad0f0b38c4ea035e60f1 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 13 Jul 2026 22:20:52 +0200 Subject: [PATCH 2/8] Treat Int128 types as bitwise equatable Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9156991f-d238-4aef-b89d-bdd9ad98ae22 --- src/coreclr/vm/jitinterface.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 51c399971c55eb..b8da06980a880c 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -7347,6 +7347,8 @@ static bool getILIntrinsicImplementationForRuntimeHelpers( || methodTable == CoreLibBinder::GetClass(CLASS__UINT32) || methodTable == CoreLibBinder::GetClass(CLASS__INT64) || methodTable == CoreLibBinder::GetClass(CLASS__UINT64) + || methodTable == CoreLibBinder::GetClass(CLASS__INT128) + || methodTable == CoreLibBinder::GetClass(CLASS__UINT128) || methodTable == CoreLibBinder::GetClass(CLASS__INTPTR) || methodTable == CoreLibBinder::GetClass(CLASS__UINTPTR) || methodTable == CoreLibBinder::GetClass(CLASS__GUID) From 0a0393f6c31d38b8bdb2d70541a1b5d28e661dac Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 13 Jul 2026 22:49:02 +0200 Subject: [PATCH 3/8] Fix integer comparison pseudo-instruction names Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9156991f-d238-4aef-b89d-bdd9ad98ae22 --- src/coreclr/jit/instr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/instr.cpp b/src/coreclr/jit/instr.cpp index 9876150b22e35e..2fc259b0921566 100644 --- a/src/coreclr/jit/instr.cpp +++ b/src/coreclr/jit/instr.cpp @@ -163,7 +163,7 @@ const char* CodeGen::genInsDisplayName(emitter::instrDesc* id) auto GetIntCmpOpName = [&](const char* suffix) -> const char* { static const char* const intCmpOpNames[] = { - "eq", "lt", "le", "neq", "false", "ge", "gt", "true", + "eq", "lt", "le", "false", "neq", "ge", "gt", "true", }; uint8_t control = static_cast(emit->emitGetInsSC(id)); From 9553218898988e653b6de428aa159a10bd3dc84f Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 13 Jul 2026 23:57:04 +0200 Subject: [PATCH 4/8] Mirror bitwise equatable types in AOT Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4b47f1ec-b319-48a6-8f7e-b621b088fd2d --- .../TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index 0ce9a5267bb92b..bbeb6cc74cd475 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -57,8 +57,12 @@ public static MethodIL EmitIL(MethodDesc method) if (elementType is MetadataType mdType) { if (mdType.Module == mdType.Context.SystemModule && - mdType.Namespace == "System.Text"u8 && - mdType.Name == "Rune"u8) + ((mdType.Namespace == "System"u8 && + (mdType.Name == "Guid"u8 || + mdType.Name == "Int128"u8 || + mdType.Name == "UInt128"u8)) || + (mdType.Namespace == "System.Text"u8 && + mdType.Name == "Rune"u8))) { result = true; } From 32dc055eaef4e53bee4d90825872b5479fd0507b Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 13 Jul 2026 23:59:38 +0200 Subject: [PATCH 5/8] Clean up AOT bitwise type recognition Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4b47f1ec-b319-48a6-8f7e-b621b088fd2d --- .../IL/Stubs/RuntimeHelpersIntrinsics.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index bbeb6cc74cd475..02cbb6925a6ba5 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -56,13 +56,7 @@ public static MethodIL EmitIL(MethodDesc method) result = false; if (elementType is MetadataType mdType) { - if (mdType.Module == mdType.Context.SystemModule && - ((mdType.Namespace == "System"u8 && - (mdType.Name == "Guid"u8 || - mdType.Name == "Int128"u8 || - mdType.Name == "UInt128"u8)) || - (mdType.Namespace == "System.Text"u8 && - mdType.Name == "Rune"u8))) + if (IsKnownBitwiseEquatableType(mdType)) { result = true; } @@ -92,5 +86,20 @@ public static MethodIL EmitIL(MethodDesc method) return new ILStubMethodIL(method, new byte[] { (byte)opcode, (byte)ILOpcode.ret }, Array.Empty(), Array.Empty()); } + + private static bool IsKnownBitwiseEquatableType(MetadataType type) + { + if (type.Module != type.Context.SystemModule) + return false; + + if (type.Namespace == "System"u8) + { + return type.Name == "Guid"u8 || + type.Name == "Int128"u8 || + type.Name == "UInt128"u8; + } + + return type.Namespace == "System.Text"u8 && type.Name == "Rune"u8; + } } } From 2d35de48b8831f46ea10507721c46151540a3c08 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Tue, 14 Jul 2026 02:14:01 +0200 Subject: [PATCH 6/8] Refactor IsKnownBitwiseEquatableType for clarity --- .../IL/Stubs/RuntimeHelpersIntrinsics.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index 02cbb6925a6ba5..3ed4ed06539e81 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -89,17 +89,18 @@ public static MethodIL EmitIL(MethodDesc method) private static bool IsKnownBitwiseEquatableType(MetadataType type) { - if (type.Module != type.Context.SystemModule) + if (type.Module != type.Context.SystemModule) + { return false; + } - if (type.Namespace == "System"u8) + ReadOnlySpan ns = type.Namespace; + if (ns == "System"u8) { - return type.Name == "Guid"u8 || - type.Name == "Int128"u8 || - type.Name == "UInt128"u8; + ReadOnlySpan name = type.Name; + return name == "Guid"u8 || name == "Int128"u8 || name == "UInt128"u8; } - - return type.Namespace == "System.Text"u8 && type.Name == "Rune"u8; + return ns == "System.Text"u8 && type.Name == "Rune"u8; } } } From 2a602ed8949fd5baa69bbe4c3359d230f1d5c7a6 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Tue, 14 Jul 2026 02:21:43 +0200 Subject: [PATCH 7/8] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index 3ed4ed06539e81..736b859f8bd4a8 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -89,7 +89,7 @@ public static MethodIL EmitIL(MethodDesc method) private static bool IsKnownBitwiseEquatableType(MetadataType type) { - if (type.Module != type.Context.SystemModule) + if (type.Module != type.Context.SystemModule) { return false; } From f0a2c7fbf92b6a4509871043aec4597aa9b14ba6 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Tue, 14 Jul 2026 02:53:06 +0200 Subject: [PATCH 8/8] Update RuntimeHelpersIntrinsics.cs --- .../Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs index 736b859f8bd4a8..7ec96db0eb5fbb 100644 --- a/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs +++ b/src/coreclr/tools/Common/TypeSystem/IL/Stubs/RuntimeHelpersIntrinsics.cs @@ -3,6 +3,7 @@ using System; +using Internal.Text; using Internal.TypeSystem; using Debug = System.Diagnostics.Debug; @@ -94,10 +95,10 @@ private static bool IsKnownBitwiseEquatableType(MetadataType type) return false; } - ReadOnlySpan ns = type.Namespace; + Utf8Span ns = type.Namespace; if (ns == "System"u8) { - ReadOnlySpan name = type.Name; + Utf8Span name = type.Name; return name == "Guid"u8 || name == "Int128"u8 || name == "UInt128"u8; } return ns == "System.Text"u8 && type.Name == "Rune"u8;