C++: x != 0 support in SimpleRangeAnalysis#4131
Closed
lcartey wants to merge 1 commit intogithub:mainfrom
Closed
Conversation
Currently != does not infer any bounds beyonds those implied by the type. However, if the rhs is a constant at the start or end of the type range, then we can infer slightly tighter bounds.
MathiasVP
reviewed
Aug 25, 2020
| // For x != RHS, we create bounds based on the size of the type, adjusted according to the RHS bounds: | ||
| // 1. if lowerbound(RHS) == typeUpperBound(RHS.getUnspecifiedType()) == upperbound(RHS) | ||
| // then | ||
| // x < lowerbound(RHS) |
Contributor
There was a problem hiding this comment.
I'm certainly buying the soundness of this, but I think it's more clear if we change this line to x < typeUpperBound(RHS.getUnspecifiedType()) to match the else case. That way, it's clear that the only change in the inferred bound is replacing a <= with a <.
And similarly for the second case below.
Contributor
There was a problem hiding this comment.
Agreed. Also, isn't it overly detailed to call getUnspecifiedType in pseudocode? What if I just remove that?
b896cbc to
a344280
Compare
Contributor
|
Superseded by #4204 |
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.
Currently != does not infer any bounds beyonds those implied by the type. However, if the rhs is a constant at the start or end of the type range, then we can infer slightly tighter bounds.