[TIR][Arith] Avoid assigning range of possible values to integers#11859
Merged
Conversation
Previously, in `ConstIntBoundAnalyzer`, entering a conditional such as `if 2==0` could result in the expression `2` being treated as having a known value of zero within the body of the conditional. Evaluating the range of expressions using `2` in the body of the conditional could result in exceptions being thrown, such as evaluating `expr / 2` while setting `2` to its maximum value of zero. This issue was present for conditions with inequalities for some time, but was introduced for conditions with equalities in apache#11524. Both types are resolved in this PR.
Contributor
Author
Member
|
Also CC: @vinx13 |
Comment on lines
+663
to
+667
| // If the conditional is comparing two integers, do not assign a | ||
| // value to them. | ||
| if (x.Eval().as<IntImmNode>()) { | ||
| return {}; | ||
| } |
Contributor
There was a problem hiding this comment.
Shouldn't this check be done first? If it's true, none of the "make bound" code above has any effect.
Contributor
Author
There was a problem hiding this comment.
I would, except that the value of x isn't set until Match returns true. So it was a choice between copy/paste of the check for IntImmNode within each conditional or potentially throwing out the result of MakeBound. Since MakeBound is a rather short constructor, I preferred keeping the condition in one spot.
kparzysz-quic
approved these changes
Jun 24, 2022
zxybazh
pushed a commit
to zxybazh/tvm
that referenced
this pull request
Jun 26, 2022
…ache#11859) Previously, in `ConstIntBoundAnalyzer`, entering a conditional such as `if 2==0` could result in the expression `2` being treated as having a known value of zero within the body of the conditional. Evaluating the range of expressions using `2` in the body of the conditional could result in exceptions being thrown, such as evaluating `expr / 2` while setting `2` to its maximum value of zero. This issue was present for conditions with inequalities for some time, but was introduced for conditions with equalities in apache#11524. Both types are resolved in this PR.
blackkker
pushed a commit
to blackkker/tvm
that referenced
this pull request
Jul 7, 2022
…ache#11859) Previously, in `ConstIntBoundAnalyzer`, entering a conditional such as `if 2==0` could result in the expression `2` being treated as having a known value of zero within the body of the conditional. Evaluating the range of expressions using `2` in the body of the conditional could result in exceptions being thrown, such as evaluating `expr / 2` while setting `2` to its maximum value of zero. This issue was present for conditions with inequalities for some time, but was introduced for conditions with equalities in apache#11524. Both types are resolved in this PR.
mikeseven
pushed a commit
to mikeseven/tvm
that referenced
this pull request
Sep 27, 2023
…ache#11859) Previously, in `ConstIntBoundAnalyzer`, entering a conditional such as `if 2==0` could result in the expression `2` being treated as having a known value of zero within the body of the conditional. Evaluating the range of expressions using `2` in the body of the conditional could result in exceptions being thrown, such as evaluating `expr / 2` while setting `2` to its maximum value of zero. This issue was present for conditions with inequalities for some time, but was introduced for conditions with equalities in apache#11524. Both types are resolved in this PR.
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.
Previously, in
ConstIntBoundAnalyzer, entering a conditional such asif 2==0could result in the expression2being treated as having a known value of zero within the body of the conditional. Evaluating the range of expressions using2in the body of the conditional could result in exceptions being thrown, such as evaluatingexpr / 2while setting2to its maximum value of zero.This issue was present for conditions with inequalities for some time, but was introduced for conditions with equalities in #11524. Both types are resolved in this PR.