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

Fix an issue where the Halide compiler hits an internal error for bool types in widening intrinsics. #8099

Merged
merged 2 commits into from
Feb 16, 2024

Conversation

zvookin
Copy link
Member

@zvookin zvookin commented Feb 16, 2024

When bool types are used with e.g. widening_mul, the compiler asserts in Type::narrow as bools cannot be narrowed. This situation did not arise from user code doing this directly, but rather through some chain of lowering with float16 types. The test cases added to correctness_intrinsics exercise the issue directly. They do fail without the fix.

I did not add broader coverage for bool types and intrinsics as it would require more thinking. Most of them overflow for the true/true case and thus are of questionable use, however widening operations cannot overflow... Certainly we could define the language to forbid this, but currently the frontend does not do so. As indicated above, the use case driving this was not using bool arithmetic to begin with.

bool types are used with e.g. widening_mul. This situation did not
arise from user code doing this directly, but rather through some
chain o lowering with float16 types. The test cases added to
correctness_intrinsics target the issue directly and do fail without
the fix.

I did not add broader coverage for bool types and intrinsics as it
would require more thinking. Most of them overflow for the true/true
case and thus are of questionable use, however widening operations
cannot overflow... Certainly we could define the language to forbid
this, but currently the frontend does not do so. As indicated above,
the use case driving this was not using bool arithmetic to begin with.
Copy link
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.

Great catch, thanks!

@abadams abadams merged commit 4fc1e57 into main Feb 16, 2024
19 checks passed
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.

3 participants