-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Comparison of add of extended booleans not folded to xor #64859
Comments
There are apparently some missing optimizations surrounding comparisons to the previous pseudo-enum. The compare of the conditional add of boolean compared to the constant 1 did not fold out. We would need to implement an optimization such as icmp eq (add (zext i1 x), (zext i1 y)), 1 => xor x, y which I filed here: llvm#64859 Just do this manually since it's more legible anyway. Saves 5 instructions for the f32 case. Change-Id: Iee7befb093561cf66b72a9df6b37d0cacb2154ee
Can I fix this? But I will need some help, as I am not familiar with LLVM system yet |
|
That would be equivalent to |
so the |
Yes, if you sketch out the truth table for this function you will see it is equivalent to the table for an xor, and with 0 it is equivalent to the table for a nor. |
So we need to create a new function |
I think |
@arsenm Here is a candidate patch : https://reviews.llvm.org/D159464 |
Can you please review the patch again. |
@arsenm |
@arsenm @nikic @goldsteinn Here's a candidate pull: #67895 |
- Add test coverage for sext/zext boolean additions - [InstCombine] Fold comparison of adding two z/sext booleans Fixes #64859.
I was looking at some code that tried to compute a sort of enum scheme by adding booleans, and comparing to constant values which failed to form nice boolean code. This is really just an xor.
https://alive2.llvm.org/ce/z/RSnV-d
The text was updated successfully, but these errors were encountered: