Skip to content

Avoid double narrowing in widening_add/widening_sub if type is 8-bit#6629

Merged
vksnk merged 1 commit intomainfrom
vksnk/narrownarrow
Feb 24, 2022
Merged

Avoid double narrowing in widening_add/widening_sub if type is 8-bit#6629
vksnk merged 1 commit intomainfrom
vksnk/narrownarrow

Conversation

@vksnk
Copy link
Copy Markdown
Member

@vksnk vksnk commented Feb 23, 2022

#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 by widening_add(x > 0 + y > 0) where type of widened_add is uint8, 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.

Change-Id: Ibc70e83da756c38b5f3c8f85826165a2fc1eadc8
@vksnk vksnk requested review from abadams and rootjalex February 23, 2022 22:33
Copy link
Copy Markdown
Member

@rootjalex rootjalex left a comment

Choose a reason for hiding this comment

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

Yikes, sorry about that. Thanks for fixing this!

@vksnk
Copy link
Copy Markdown
Member Author

vksnk commented Feb 24, 2022

The test failure seems to be unrelated, so merging in.

@vksnk vksnk merged commit caa3ad0 into main Feb 24, 2022
@alexreinking alexreinking deleted the vksnk/narrownarrow branch April 6, 2022 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants