Skip to content

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Jul 23, 2025

Fixes #116125

Introduced in #113037

Zero diffs

@Copilot Copilot AI review requested due to automatic review settings July 23, 2025 00:47
Copy link
Contributor

@Copilot 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 PR fixes a JIT compilation bug where shift and rotate operations incorrectly reported that they support setting the zero flag in all cases. The fix ensures that shift/rotate instructions only claim to support setting the zero flag when the shift count is guaranteed to be non-zero, since x86 shift/rotate instructions don't update flags when the count is zero.

  • Adds proper condition checking for shift/rotate operations in SupportsSettingZeroFlag()
  • Includes a regression test that reproduces the original issue
  • Separates shift/rotate logic from other arithmetic operations that unconditionally support zero flag setting

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/coreclr/jit/gentree.cpp Updated SupportsSettingZeroFlag() to check if shift count is non-zero for shift/rotate operations
src/tests/JIT/Regression/JitBlue/Runtime_116125/Runtime_116125.cs Added regression test with division by shift result that triggers the bug
src/tests/JIT/Regression/JitBlue/Runtime_116125/Runtime_116125.csproj Test project configuration with optimization enabled

@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 23, 2025
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@EgorBo
Copy link
Member Author

EgorBo commented Jul 23, 2025

PTAL @jakobbotsch @dotnet/jit-contrib simple change - I've checked it with Intel and AMD manuals. Also, native compilers do similar checks.

@EgorBo EgorBo merged commit c11b0e0 into dotnet:main Jul 23, 2025
114 of 117 checks passed
@EgorBo EgorBo deleted the shift-rotate-flags-bugfix branch July 23, 2025 13:03
@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fuzzlyn] Incorrect T1 behavior around division

2 participants