Fix SupportsSettingZeroFlag for shift/rotate nodes#117960
Fix SupportsSettingZeroFlag for shift/rotate nodes#117960EgorBo merged 2 commits intodotnet:mainfrom
Conversation
There was a problem hiding this comment.
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 |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
PTAL @jakobbotsch @dotnet/jit-contrib simple change - I've checked it with Intel and AMD manuals. Also, native compilers do similar checks. |
Fixes #116125
Introduced in #113037
Zero diffs