Skip to content

Conversation

@jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Aug 4, 2025

#113178 switched returned promoted structs to always be morphed to FIELD_LIST and started handling the introduced FIELD_LIST in the backend. However, this change introduced new unnecessary normalization when returning promoted structs that previously would not happen with the old LowerRetSingleRegStructLclVar code path.

This change adds an optimization to get rid of the introduced normalization when possible.

Fix #113382

For the benchmark:

Method Toolchain Mean Error StdDev Median Min Max Ratio Allocated Alloc Ratio
WriteHalf pr 3.635 ns 0.0113 ns 0.0100 ns 3.635 ns 3.616 ns 3.657 ns 0.93 - NA
WriteHalf main 3.913 ns 0.0146 ns 0.0137 ns 3.911 ns 3.885 ns 3.935 ns 1.00 - NA

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 4, 2025
@jakobbotsch
Copy link
Member Author

/azp run Fuzzlyn

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jakobbotsch jakobbotsch marked this pull request as ready for review August 5, 2025 08:51
Copilot AI review requested due to automatic review settings August 5, 2025 08:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This change optimizes the JIT by removing redundant normalizing casts when returning promoted structs. It addresses a performance regression introduced by #113178 which forced all returned promoted structs to use FIELD_LIST morphing, leading to unnecessary normalization that didn't exist in the previous LowerRetSingleRegStructLclVar code path.

Key changes:

  • Removes genActualType() call when determining register types for return field lists
  • Adds optimization logic to eliminate unnecessary casts on the last register entry when returning structs

@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @amanasifkhalid

Opened #118377 for the Fuzzlyn issue.

Diffs. Pretty minor, but affects the micro benchmark.

@jakobbotsch jakobbotsch merged commit 824fdb1 into dotnet:main Aug 5, 2025
118 of 120 checks passed
@jakobbotsch jakobbotsch deleted the fix-113382 branch August 12, 2025 13:21
@github-actions github-actions bot locked and limited conversation to collaborators Sep 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Perf] Linux/x64: System.IO.Tests.BinaryWriterTests Regression on 3/8/2025 7:47:21 PM +00:00

2 participants