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
JIT: Lift remaining cmov restrictions by introducing GT_SELECTCC #82235
JIT: Lift remaining cmov restrictions by introducing GT_SELECTCC #82235
Changes from 6 commits
0a64817
809d075
e54486c
02c2e32
0c022c7
01daf11
d3dc0c7
8577618
47e146c
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.
Is there any difference between a GenTreeOpCC and a GenTreeConditional?
If not, I assume it's here just to help with categorising nodes.
Could GenTreeOpCC be a subclass of GenTreeConditional (or vice versa?)
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.
Yes --
GenTreeOpCC
is a binary node with a condition code in it. As such, it only makes sense in the backend with explicit ordering where the flags definition can happen right before it. There is no explicit link to the flags definition (at least until #82355, though this is just an experiment for now).So it's sort of a lowered version of
GenTreeConditional
.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 didn't spot this at first but
GenTreeOpCC
does not have a pointer to the genTree for the condition, except via gtPrev. I see thatGenTreeCC
works in the same way. That feels odd at first, but this is LIR, and it's the prev/next that matter. Ok, I'm happy with how that works now.Thinking about the CCMP nodes, they would also use
GenTreeOpCC
. We'd need aCCMP
node plus all 6 conditions (CCMP_EQ
,CCMP_NE
,CCMP_LT
, etc).Coming from HIR we have:
OptimizeConstCompare() will lower to a TEST_EQ:
Then lowerCompare() will create a CCMP and CMP:
Finally LowerJtrue() will create the JCC:
Which means I need to wait for this PR before I can continue with the CCMP work.
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.
That sounds good to me. Feel free to lift any of the code from this PR if it helps.
Note that this PR is teaching
TryLowerConditionToFlagsNode
aboutGT_SETCC
nodes. I think I had a note on it somewhere else, but I wouldn't expect the 6 combinations to be necessary due to that. I.e. we can representCCMP_LT
asCCMP + SETCC[LT]
. The transformation done in this PR will automatically lowerJTRUE(SETCC[LT])
intoJCC[LT]
.I think it's likely compare chains can end up being handled similarly to this, that is, something like
AND(SETCC[cond], x)
can be turned into some shape ofCCMP + SETCC
and then lowering will continue working on these successively (haven't worked out the details).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 that scheme:
Coming from HIR we have:
OptimizeConstCompare() will lower to a TEST_EQ:
Then lowerCompare() will create a CCMP, SETCC and CMP:
Finally LowerJtrue() will create the JCC:
I'm happy with that setup.
It's not clear to me how much of the existing AND chains code will be left in codegen after this, but that can be checked 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.
Should SELECTCC here be a GenTreeOpCC ?
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.
Yes, it should. Doesn't look like it has any impact since we only use this for some node measuring that can be turned on, but I will keep in mind to fix it in a follow-up.