-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Arm64: Add If conversion pass #73472
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
ea2f3d5
Arm64: Add If conversion pass
a74nh 8ee167f
Minor review fixups
a74nh 039de48
Return a PhaseStatus
a74nh ddfad68
Fix formatting
a74nh 41c3a9e
Check for side effects on NOPs
a74nh 4c93a4c
Add function block comments for the phase
a74nh 891510d
Remove creation of AND chains from if conversion pass
a74nh c1281b5
Update middleBlock flow
a74nh b900344
Check for order side effects
a74nh a3e89b9
Remove COLON_COND check
a74nh 441a60c
Remove flag toggling
a74nh 962c83b
Move the conditional assignment to the JTRUE block
a74nh 90bff39
Fix formatting
a74nh 36cf21d
Allow conditions with side effects
a74nh 127f9a6
Fix formatting
a74nh d1f0862
Correct all moved SSA statements
a74nh 852a5af
Add size costing check
a74nh 6690566
Only move middle block ssa defs
a74nh 58372e2
Fix formatting
a74nh 10a8f1f
Fewer SSA assumptions
a74nh 97b1af1
Use implicit func for value numbering
a74nh 3f60851
Update header for gtFoldExprConditional
a74nh 0f054fe
Cost based on speed
a74nh 6f0abdf
Merge branch 'main'
a74nh 393fd39
Add Stress mode for inner loops
a74nh 09d62fe
Rework costings
a74nh 73007b2
Check for invalid VNs
a74nh 61af92d
Ignore compares against zero
a74nh 4fdabea
Ensure float compares are contained
a74nh be60d30
Allow if conversion of test compares
a74nh 806e061
Do not contain test compares within compare chains
a74nh a508e85
Add float versions of the JIT/opt/Compares tests
a74nh ac2568f
Fix formatting
a74nh bad8097
Compare chains use CmpCompares, selects use Compares
a74nh ed06f67
Merge main
a74nh 935716c
Fix flow checking for empty blocks
a74nh 12bfe0a
Merge main
a74nh f2f3a02
Fix to contexts setting JitStdOutFile
jakobbotsch 2e183bd
Temporary fix for SPMI problem
jakobbotsch b2772ff
Fix attr and reg producing in select generation
a74nh 4281fc0
Revert SPMI changes
jakobbotsch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add size costing check
- Loading branch information
commit 852a5afdd66327d05b8abab13190da00ff72097d
There are no files selected for viewing
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
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
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.
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.
Ideally we would fix the costing instead. We should not be working around incorrect costing like this.
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.
It's not clear to me that this is really the heuristic we want, barely anything in the JIT uses code size estimates when optimizing for speed (the places that do are more about code duplication -- which this transformation does not do).
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 would stick with Andy's suggestion here -- put a constant limit on
GetCostEx()for the code that is now being evaluated eagerly. We can adjust the heuristic as needed once we get some mileage on the transformation.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.
Agreed optimising for speed is better than size.
But - by optimising for speed I always see regressions via spmidiff. That's due the costings not taking into account that comparison against 0 will get optimised away into cbnz.
With everything enabled:
[14:50:56] Total bytes of base: 138017016 (overridden on cmd)
[14:50:56] Total bytes of diff: 138022692 (overridden on cmd)
[14:50:56] Total bytes of delta: 5676 (0.00 % of base)
[14:50:56] 567 total methods with Code Size differences (87 improved, 480 regressed), 783 unchanged.
Limiting via costEx:
[14:54:47] Total bytes of base: 138017992 (overridden on cmd)
[14:54:47] Total bytes of diff: 138021404 (overridden on cmd)
[14:54:47] Total bytes of delta: 3412 (0.00 % of base)
[14:54:47] 281 total methods with Code Size differences (42 improved, 239 regressed), 572 unchanged.
This is using the following for costing:
But, if speed is what we're looking for, then yes, checking spmidiff isn't that useful
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.
Sounds like something we ought to fix, if you have free cycles can you submit a separate PR for it?
Evaluating the cost of the LHS of assignments uncontextually is odd since it is treated specially ("no cost" if it ends up being a local in a register, for example).
gtSetEvalOrderusesgtIsLikelyRegVarto estimate this, does it make sense to take it into account? Basically, in that case the cost ofASG(lcl, SELECT(...))is only going to be the cost ofSELECTwhen evaluated into a target register.I was really just thinking of something like:
Taking
cbnzinto account as you mentioned would be great. Exact values need to be adjusted, for example maybe pick the number such that we allow conversion forx = cond ? a + b : x, but no more than that. By the way, clang seems really aggressive: https://godbolt.org/z/54GMGaTfYI'm not that worried about the size wise regressions.
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.
Sure, wasn't sure if it was intentional. I'll do that and the incorrect size one too.
Will try this out.
I'm not certain on this, but, I think in later passes clang will sometimes turn the if conversions back into branches (maybe as part of auto vec).
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.
Updated costings and set the Stress to 25%.
Limit of 7 to allow for: