Skip to content
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

Fixes to bounds inference on shift_left #5477

Merged
merged 22 commits into from Dec 4, 2020
Merged

Conversation

rootjalex
Copy link
Member

@rootjalex rootjalex commented Nov 25, 2020

One of the shift_left rules (for the min of an interval) was incorrect, but can only be replaced by weaker rules. All of the added rules have been formally verified.
@abadams @dsharlet

Edit: I closed the original draft for this PR (#5476) to get the buildbots to run tests

@rootjalex rootjalex added the bug label Nov 25, 2020
@rootjalex
Copy link
Member Author

Note: when these changes are merged, they should be squashed. Some of the intermediate commits have buggy code as I had some commits that relied on shift behaviors that are not currently expected behavior (dealing with overflow).

src/Bounds.cpp Outdated Show resolved Hide resolved
src/Bounds.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@steven-johnson steven-johnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite follow the logic of the intended fixes, but my brain is tired. I'll look again tomorrow.

@@ -1235,8 +1235,26 @@ class Bounds : public IRVisitor {
!b_interval.min.type().is_uint() &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the case that b_interval.min and b_interval.max are always the same type? (i.e., this implies that b_interval.max is also a non-uint?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that this should be the case, but @abadams might contradict me. I have been operating under the assumption that that invariant is maintained.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Would be nice to have that documented somewhere, though that's orthogonal to this PR.)

I ask mainly because code lower down seemed to be optimized based on that assumption, but it wasn't clear to me whether deliberate or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, all of the changes I have made to bounds inference assumes that the type of the min, type of the max, and type of the operation are all equal.

src/Bounds.cpp Outdated Show resolved Hide resolved
@rootjalex
Copy link
Member Author

rootjalex commented Nov 26, 2020

@steven-johnson Any idea what the test failures are caused by?

Edit: this question might be null-ed out because I need to add a change. Let's see.

@steven-johnson
Copy link
Contributor

What's the work remaining on this PR?

@rootjalex rootjalex marked this pull request as ready for review December 3, 2020 00:39
@rootjalex
Copy link
Member Author

None, it can be merged if you and @abadams are happy with it. Sorry for the delay!

@steven-johnson
Copy link
Contributor

The failures all appear unrelated, good to merge I think

@rootjalex rootjalex merged commit c1885fc into master Dec 4, 2020
@rootjalex rootjalex deleted the rootjalex/shift_left_fix branch December 4, 2020 00:14
@alexreinking alexreinking added this to the v11.0.0 milestone Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants