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
Eliminate redundant test instruction #53214
Eliminate redundant test instruction #53214
Changes from 8 commits
06dda15
b6f80ea
8867374
01fb6ba
81eb9eb
53c4325
7ded469
e7e04b7
b1e0fc3
068fb15
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.
I think this might require some careful considerations.
For the purposes of this PR, this is fine and is simply used as a "did the previous instruction set the flag and therefore a
test
can be skipped" check.However, for future improvements we may consider more advanced analysis such as:
Then, this will become problematic. The latter happens in Clang/MSVC in various places and are one of the reasons that
mulx
,rorx
,sarx
,shlx
, andshrx
are exposed on modern hardware.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.
Perhaps we can return some ternary state here representing "yes", "no", and "it depends"?
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.
Today, we only track prevInstruction (
emitLastIns
). The way I read your comment, we will need to have access to last couple of instructions (if not more) to make sure the state is valid?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.
Right, it's not something I think we need to be concerned with "today", but rather something I could see being problematic in the future for certain optimizations.
The method implies boolean state but in practice its slightly more nuanced and one of the answers is "maybe", so it may end up confusing callers.
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.
Exactly - what are callers supposed to do with "maybe". So for now, I will leave it as-is.
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 that is contextual. In the case of this PR, you care "did the last instruction definitely set the flag I care about" and so you would treat
maybe
asfalse
.In other cases, optimizations may care "did the last instruction definitely not set the flag I care about" and so they would treat it as
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.
Renamed the method to
IsFlagsAlwaysModified
.