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

Redirect bitwise ops to logical ops in case the arguments are bool. #8597

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mcourteaux
Copy link
Contributor

@mcourteaux mcourteaux commented Mar 17, 2025

This fixes an explicit type error on the WebGPU backend, where WGSL is not allowing bool ^ bool. Fixes #8596.

@abadams abadams added the dev_meeting Topic to be discussed at the next dev meeting label Mar 20, 2025
@abadams
Copy link
Member

abadams commented Mar 20, 2025

Failures unrelated. This makes sense, but this seems bordering on a language semantics change, and raises the oddity of having a bitwise_and intrinsic that's distinct from the And node even though they're identical for bools. I want to make sure we discuss this briefly in a dev meeting just to get a sanity check from others.

@mcourteaux
Copy link
Contributor Author

mcourteaux commented Mar 20, 2025

I think the main argument is that Halide doesn't have a boolean type, and instead relies on uint1. So really we cannot make the distinction between a 1-bit int, and a boolean. So either we remove all logical operators (and say everything is an int, and therefore there are no logical operators to be defined on ints). Or we make the bitwise operators on uint1 redirect to logical operators.

Also note that the Python bindings do not even expose the logical AND operator (because python does not allow to override it), and instead relies on the users to use bitwise-AND & and bitwise-OR |.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev_meeting Topic to be discussed at the next dev meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binary bitwise operators ^, &, | should be invalid on Bools.
2 participants