-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
FindIntrinsics creates incorrect IR for casts from bool to arithmetic type #6601
Comments
This issue is coming from here: https://github.com/halide/Halide/blob/1e7040c9ab44c31b4754aa0cdd3ca0555c8f8142/src/FindIntrinsics.cpp#L217-#L218 Which allows for this rewrite:
As long as a and b can be losslessly cast to uints with The same problem also appears exists for add, but I imagine this is rather difficult to trigger: https://github.com/halide/Halide/blob/1e7040c9ab44c31b4754aa0cdd3ca0555c8f8142/src/FindIntrinsics.cpp#L187-#L188 |
Minor nit: I think it allows for the rewrite
FWIW, this used to be in the Hexagon backend in Halide for the widening_add & sub operations which Dillon pulled into FindIntrinsics. We didn't however apply this to booleans. May be the check for types needs to be more restrictive. |
@pranavb-ca I'm not sure what the difference is, could you elaborate? The cast back to float comes from here: Line 232 in 1e7040c
I agree that this should probably be more strict on types, but I'm also wondering if this rewrite should be valid for, e.g.:
|
I apologize, you are right @rootjalex. Since in the Hexagon backend we used to restrict it to the same type (different width) I assumed that was the case here as well. |
Oh no worries @pranavb-ca ! Thanks for the clarification! |
Here's a small repro:
Building for a GPU target results in:
Drilling down a bit, what I'm seeing is that the IR after FindIntrinsics includes expressions like:
The text was updated successfully, but these errors were encountered: