Simplify Enum.Equals/GetHashCode optimization#123086
Merged
MichalStrehovsky merged 1 commit intodotnet:mainfrom Jan 12, 2026
Merged
Simplify Enum.Equals/GetHashCode optimization#123086MichalStrehovsky merged 1 commit intodotnet:mainfrom
MichalStrehovsky merged 1 commit intodotnet:mainfrom
Conversation
This is basically a revert of dotnet/corert#2117 and port of dotnet/coreclr#7895 instead. Now that RyuJIT implements the optimization for `Equals` (dotnet#122779), we only need `GetHashCode` and the `GetHashCode` optimization can be implemented the same way how it's implemented on CoreCLR VM.
Contributor
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies the enum GetHashCode optimization by removing custom IL thunk generation and instead leveraging RyuJIT's built-in optimization for Equals (added in PR #122779) and using a simpler approach for GetHashCode that's consistent with CoreCLR VM.
Changes:
- Removed custom EnumEqualsThunk and EnumGetHashCodeThunk IL stub classes (no longer needed since RyuJIT handles Equals optimization directly)
- Simplified GetHashCode optimization to replace enum type with its underlying type during constrained call resolution
- Updated project files to remove references to deleted enum thunk files
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs | Added simplified enum GetHashCode optimization that replaces enum type with underlying type |
| src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs | Added matching enum GetHashCode optimization for the IL scanner |
| src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj | Removed references to deleted EnumThunks and EnumMethods files |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs | Removed call to GetAllMethodsForEnum since enum thunks are no longer needed |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.EnumMethods.cs | Deleted - enum method resolution no longer needed |
| src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.cs | Deleted - IL thunks for enum Equals/GetHashCode no longer needed |
| src/coreclr/tools/Common/TypeSystem/IL/Stubs/EnumThunks.Sorting.cs | Deleted - sorting support for deleted EnumThunks |
This was referenced Jan 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is basically a revert of dotnet/corert#2117 and port of dotnet/coreclr#7895 instead.
Now that RyuJIT implements the optimization for
Equals(#122779), we only needGetHashCodeand theGetHashCodeoptimization can be implemented the same way how it's implemented on CoreCLR VM.Cc @dotnet/ilc-contrib @EgorBo