Skip to content

Cranelift bitops mid-end optimization rules - #14233

Merged
cfallin merged 1 commit into
bytecodealliance:mainfrom
yagehu:opt
Aug 31, 2026
Merged

Cranelift bitops mid-end optimization rules#14233
cfallin merged 1 commit into
bytecodealliance:mainfrom
yagehu:opt

Conversation

@yagehu

@yagehu yagehu commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

This commit adds several bitops mid-end optimization rules and filetests that target them. These filetests fail to optimize on main without these new rules.

~x ^ ~y       -->  x ^  y
~x & (x ^ y)  --> ~x &  y
x & (x ^ y)   -->  x & ~y
~(~x ^ y)     -->  x ^  y
x ^ (x & y)   -->  x & ~y
(x | y) ^ y   -->  x & ~y

This commit adds several bitops mid-end optimization rules and
filetests that target them. These filetests fail to optimize on main
without these new rules.

```
~x ^ ~y       -->  x ^  y
~x & (x ^ y)  --> ~x &  y
x & (x ^ y)   -->  x & ~y
~(~x ^ y)     -->  x ^  y
x ^ (x & y)   -->  x & ~y
(x | y) ^ y   -->  x & ~y
```

Co-authored-by: Zijian Yi <zijianyi66@gmail.com>
@yagehu
yagehu requested a review from a team as a code owner August 29, 2026 15:03
@yagehu
yagehu requested review from cfallin and removed request for a team August 29, 2026 15:03
@github-actions github-actions Bot added cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language labels Aug 29, 2026
@github-actions

Copy link
Copy Markdown

Subscribe to Label Action

cc @avanhatt, @cfallin, @fitzgen, @mmcloughlin

Details This issue or pull request has been labeled: "cranelift", "isle"

Thus the following users have been cc'd because of the following labels:

  • avanhatt: isle
  • cfallin: isle
  • fitzgen: isle
  • mmcloughlin: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@cfallin cfallin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and the verifier passes, with new SMT queries executed -- thanks!

@cfallin
cfallin added this pull request to the merge queue Aug 31, 2026
Merged via the queue into bytecodealliance:main with commit dde570a Aug 31, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants