JIT: Enable fgOptimizeRelationalComparisonWithCasts for EQ/NE#128091
Open
BoyBaykiller wants to merge 1 commit into
Open
JIT: Enable fgOptimizeRelationalComparisonWithCasts for EQ/NE#128091BoyBaykiller wants to merge 1 commit into
fgOptimizeRelationalComparisonWithCasts for EQ/NE#128091BoyBaykiller wants to merge 1 commit into
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
fe6c9b2 to
4654abb
Compare
BoyBaykiller
commented
May 21, 2026
| return cmp; | ||
| } | ||
|
|
||
| assert(genActualType(cmp->gtGetOp1()) == genActualType(cmp->gtGetOp2())); |
Contributor
Author
There was a problem hiding this comment.
Reason I moved this down:
When calling this function for EQ/NE this assert fired in some coreclr_tests. And moving it after the supportedOp check fixes it. This is the tree it failed on:
[000030] --CXG------ * EQ int
[000013] --CXG+----- +--* CALL help ref CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL
[000469] n---G+----- arg0 rcx | \--* IND byref
[000468] -----+----- | \--* ADD byref
[000011] -----+----- | +--* LCL_VAR byref V01 arg1
[000467] -----+----- | \--* CNS_INT long 8
[000029] ----G+---U- \--* CAST long <- uint
[000470] ----G+----- \--* EQ int
[000473] n---G+----- +--* IND byref
[000472] -----+----- | \--* ADD byref
[000018] -----+----- | +--* LCL_VAR byref V02 arg2
[000471] -----+----- | \--* CNS_INT long 8
[000476] n---G+----- \--* IND byref
[000475] -----+----- \--* ADD byref
[000025] -----+----- +--* LCL_VAR byref V03 arg3
[000474] -----+----- \--* CNS_INT long 8
BoyBaykiller
commented
May 21, 2026
| // TODO-CQ: Should be called for all comparisons | ||
| if (tree->OperIs(GT_LT, GT_LE, GT_GE, GT_GT) && | ||
| (tree->gtGetOp1()->OperIs(GT_CAST) || tree->gtGetOp2()->OperIs(GT_CAST))) | ||
| if (tree->OperIsCmpCompare() && (tree->gtGetOp1()->OperIs(GT_CAST) || tree->gtGetOp2()->OperIs(GT_CAST))) |
Contributor
Author
There was a problem hiding this comment.
This is the (only) meaningful change.
Contributor
Author
|
@EgorBo PTAL. Simple change |
EgorBo
reviewed
May 21, 2026
| { | ||
| assert(cmp->OperIsCmpCompare()); | ||
| assert(cmp->gtGetOp1()->OperIs(GT_CAST) || cmp->gtGetOp2()->OperIs(GT_CAST)); | ||
| assert(genActualType(cmp->gtGetOp1()) == genActualType(cmp->gtGetOp2())); |
Member
There was a problem hiding this comment.
why? if you think this assert is incorrect you should fix it, not move it to somewhere to silence it
Contributor
Author
There was a problem hiding this comment.
Hm, doesn't it make sense to move it after the supportedOp check
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We were previously only calling that for
GT_LT, GT_LE, GT_GE, GT_GT.Example: