Skip to content

[Cranelift] add simplification rules#12799

Open
myunbin wants to merge 13 commits intobytecodealliance:mainfrom
myunbin:add-rules-180326
Open

[Cranelift] add simplification rules#12799
myunbin wants to merge 13 commits intobytecodealliance:mainfrom
myunbin:add-rules-180326

Conversation

@myunbin
Copy link
Contributor

@myunbin myunbin commented Mar 18, 2026

This PR adds several simplification rules:

arithmetic.isle

  • ((x + y) - (x + z)) --> (y - z)
  • ((x - z) - (y - z)) --> (x - y)
  • ((x - y) - (x - z)) --> (z - y)
  • min(x, y) + max(x, y) --> x + y
  • ((x - y) + (y + z)) --> (x + z)
  • (x - (x + y)) --> -y
  • (x + (y + (z - x))) --> (y + z)
  • (x + y) == (y + x) --> true
  • (x - y) != x --> y != 0

bitops.isle

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

cc @bongjunj

@myunbin myunbin requested a review from a team as a code owner March 18, 2026 09:30
@myunbin myunbin requested review from alexcrichton and removed request for a team March 18, 2026 09:30
@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language labels Mar 18, 2026
@github-actions
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

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

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

  • cfallin: isle
  • fitzgen: isle

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

Learn more.

@myunbin
Copy link
Contributor Author

myunbin commented Mar 19, 2026

I’m trying to identify the reason for the CI failure, but since it’s difficult to check on local environment, I will check various scenarios.

I would appreciate it if you could ignore this PR until it is completed.

@alexcrichton alexcrichton requested review from fitzgen and removed request for alexcrichton March 20, 2026 06:26
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.

1 participant