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.
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
Arm64: Combine if conditions into compare chains #79283
Arm64: Combine if conditions into compare chains #79283
Changes from 29 commits
3aa62af
48b68ec
56ff631
a919a13
893cbb5
31c8560
60341f3
177c92a
62dabf4
ca38951
2360f26
8323f71
bef86f0
3bdceeb
adf6b99
5b99a4d
e8ebd2a
748252f
6a94a6e
8846bc3
1350849
f056765
a690be6
02bbafe
8fcef67
e7f4369
7f9fdb8
3d8ed4f
191a650
6cf9cd3
18ea05c
238d810
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Did you end up adding some handling for potentially expensive trees somewhere else?
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.
We're iterating forwards through the blocks now, so that I think gets rid of that issue:
if (expensive1 || cheap1 )
if (expensive1 || cheap1 || cheap2 )
if (cheap1 || cheap2 || expensive1)
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 odd to me that it's possible to "defeat" the check:
this produces:
Of course it's a very constructed example but I would be afraid that there are more natural looking examples.
I suppose to fix this you would need the recursive walk you wanted to avoid. I don't think that's expensive -- the code below calls
gtSetEvalOrder
andfgSetStmtSeq
and they both end up doing these kinds of full tree walks anyway -- but it's not as elegant. It would make me feel a bit more at ease, however, to find and limit the cost of each "leaf" in the compare chain.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 think we can leave it as is, it's probably fine in practice. Will leave it up to you.
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.
The cost of
(((a * a * a * a * a > 3) & (a == 20))
is 35, which is on the limit for combing with thea > 10
Whereas the cost after combining, for example,
op1 > 3 && op2 == 10 && op3 >= 12
is 32. (It's fairly high because of the two lots of EQ(AND,0)).Looking at this again, a limit of 35 is probably too high as it's allowing 4 items to chain together. I should probably drop it to 31 to prevent
op1 > 3 && op2 == 10 && op3 >= 12
combing with anything else.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.
With the new costing it'll still allow like
(((a * a * a * a > 3) & (a == 20))
(ie one less than you had before).To improve it, further I think we'd have to somehow remove all the EQ(AND,0) blocks from the costings (as we know they'll vanish during lowering). Not sure it's worth it, so happy to leave as is now.