- Notifications
You must be signed in to change notification settings - Fork 5.2k
Do not block folding of unsigned (and unordered) comparisons in value numbering #48568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not block folding of unsigned (and unordered) comparisons in value numbering #48568
Conversation
| Nice! Do you need any help with the asserts (look related)? Also, could you please run a full jit-diff (not just corelib) |
Thank you! Hopefully fixing those will be straightforward enough.
Of course! Was holding off so that the final diffs are for the full and proper fix. |
10f1336 to 5c3abf2 Compare | With basic CI passing, posting diffs collected with SPMI: The diffsTwo regressions: magic division expansion and a lonely CSE. It would be good to run the outerloop. |
src/coreclr/jit/valuenum.cpp Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have tests for comparisons with NaN (as a constant, not Xunit arg)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ls *.cs -r | sls "(<=|==|>=|<|>|!=) ?(double|float).NaN ?(<=|==|>=|<|>|!=)" in src/tests finds nothing, as does manual looking at ls *.il -r | sls "ldc.r(4|8)" which suggests we do not have great coverage for this. There are tests in libs that cover some NaN folding, but I would be very surprised to see them ever hit this path (unordered compares are generally seen when Jit inverts the condition, and those tests are too simple for that).
It is somewhat surprising that's the case, I will look into improving the coverage. Testing this particular change is tricky because it runs late'ish, hopefully I will be able to figure out something out though.
5c3abf2 to a1039d9 Compare …mStore::VNForFunc
| With the core changes not expected to be in flux, posting some updated diffs (obtained via Some tests have been partially foldedAs an example of a positive diff, the whole Note for reviewers: all the hand-written changes are in the first 4 commits, all the |
| @briansull PTAL |
briansull left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good
| // always returns true | ||
| return false; | ||
| // unordered comparisons with NaNs always return true | ||
| return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this a bug before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe so, yes.
| Merging |
These were blocked and it was causing issues for unrolling as the unroller substitutes iterator variables with constants, but if the comparison is unsigned (in other words, the
(uint)index >= Lengthtrick was used), later phases do not clean it up. The code to actually handle the folding is already there:runtime/src/coreclr/jit/valuenum.cpp
Line 862 in a350bc6
runtime/src/coreclr/jit/valuenum.cpp
Lines 889 to 904 in a350bc6
The diffs (with
--pmi) are as expected:Vector methods
An example.
Draft for now to test this in CI.