-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Cranelift: or(x, C) + (-C) --> and(x, ~C)
#10979
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
Conversation
Subscribe to Label Action
This issue or pull request has been labeled: "cranelift", "isle"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just a couple minor nitpicks below.
Out of curiosity, did you find this code pattern in the wild? Synthesize it? Something else?
@@ -366,3 +366,17 @@ block0(v0: i16, v1: i16, v2: i16): | |||
; check: v12 = iadd v0, v1 | |||
; check: v15 = iadd v12, v2 | |||
; check: return v15 | |||
|
|||
;; or(x, C) + (-C) --> and(x, ~C) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this summary comment to the ISLE rule? Thanks!
Looks like this optimization applied to one of our existing test cases in CI, changing its golden output. You can update the output via
And then commit that test expectation update and include it in this PR. |
Hi, thanks for the comment.
Actually I'm collecting these code patterns from LLVM using some kind of synthesizer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Nice! I'd love to hear a little more about this. Are you harvesting LHSes via LLVM and then synthesizing RHSes directly for ISLE? Or synthesizing RHSes for LLVM and porting them to ISLE? Are you using Souper or a different synthesizer? FWIW, we have some Souper-synthesized rules that we haven't completed landing (mostly because I don't have time) over in #5783 And we also have some infrastructure for harvesting Souper LHSes from CLIF input. The following command will harvest LHSes from the
And then we also have a helper script to run Souper. This will take those harvested LHSes from the previous step and run Souper on each of them. For each RHS that it finds, it will write a
As far as getting the initial CLIF input goes for the above commands, Wasmtime has a
|
My synthesizer construct the LHS and RHS from the input and the output programs of LLVM optimizers. Most of the job is done by deterministic mapping from LLVM opcode to Cranelift ones. But the remaining part of synthesizing relationships among constants is the problem Im solving. Thanks for the idea using souper. I will take a look into that. |
This add
or(x, C) + (-C) --> and(x, ~C)
proof.isle