Avoid double narrowing in widening_add/widening_sub if type is 8-bit#6629
Merged
Avoid double narrowing in widening_add/widening_sub if type is 8-bit#6629
Conversation
Change-Id: Ibc70e83da756c38b5f3c8f85826165a2fc1eadc8
rootjalex
approved these changes
Feb 23, 2022
Member
rootjalex
left a comment
There was a problem hiding this comment.
Yikes, sorry about that. Thanks for fixing this!
Member
Author
|
The test failure seems to be unrelated, so merging in. |
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.
#6622, specifically making narrowing of uint1 an error broke some of our internal tests. The simplest reproducer would be an expression like
u8(x > 0) + u8(y > 0), which would get replaced bywidening_add(x > 0 + y > 0)where type ofwidened_addisuint8, which later at https://github.com/halide/Halide/blob/main/src/FindIntrinsics.cpp#L620 will get narrowed twice and cause u8->u1->error.Here I just looked for all places where narrow().narrow() happens and added a check to make sure that type has at least 16-bit, which seems to fix all failing tests I was seeing.