myunbin opened PR #13850 from myunbin:add-rules-20260709-012308 to bytecodealliance:main:
Add and modify simplification rules.
arithmetic.isle
-(~x) --> x + 1~(-x) --> x - 1-1 - x --> ~x
bitops.isle
- Modified rule
x ^ x --> 0to support vector types.
extends.isle
- Keep only the narrowest type version.
icmp.isle
- Add two rules:
~x == x --> 0,~x != x --> 1- Modified rules for variants of
x == x --> 1to support vector types.
shifts.isle
- All zeros/ones remain all zeros/ones for arithmetic right shifts or rotates.
For example,0 << x --> 0or(-1) >>s x --> (-1).
myunbin requested fitzgen for a review on PR #13850.
myunbin requested wasmtime-compiler-reviewers for a review on PR #13850.
myunbin edited PR #13850:
Add and modify simplification rules.
arithmetic.isle
-(~x) --> x + 1~(-x) --> x - 1-1 - x --> ~xbitops.isle
- Modified rule
x ^ x --> 0to support vector types.extends.isle
- Keep only the narrowest type version.
icmp.isle
- Add two rules:
~x == x --> 0,~x != x --> 1- Modified rules for variants of
x == x --> 1to support vector types.shifts.isle
- All zeros/ones remain all zeros/ones for arithmetic right shifts or rotates.
For example,0 << x --> 0or(-1) >>s x --> (-1).
myunbin requested wasmtime-core-reviewers for a review on PR #13850.
myunbin updated PR #13850.
myunbin updated PR #13850.
myunbin updated PR #13850.
myunbin updated PR #13850.
myunbin updated PR #13850.
myunbin updated PR #13850.
myunbin updated PR #13850.
github-actions[bot] added the label cranelift on PR #13850.
github-actions[bot] added the label isle on PR #13850.
github-actions[bot] commented on PR #13850:
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 <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
:memo: fitzgen submitted PR review:
LGTM, modulo one small concern below. Thanks!
:speech_balloon: fitzgen created PR review comment:
We allow
bxoron floats and vector types and I suspect that this changed rule may break when given a float or vector of floats. Can you add a filetest forbxor x, xon those types if we don't already have one, and make sure that it passes?
:speech_balloon: fitzgen created PR review comment:
Ah okay, here is the test.
Can we also exercise floats and a vector of floats? Thanks!
myunbin updated PR #13850.
myunbin commented on PR #13850:
@fitzgen As you suspected,
bxordid not work for floats or vectors of floats. I updated
the rule to support both cases and added tests.
myunbin edited a comment on PR #13850:
@fitzgen As you suspected,
bxordid not work for floats or vectors of floats. I updated
the rule to support both cases and added tests. Thanks for pointing it out!
myunbin updated PR #13850.
:memo: myunbin submitted PR review.
:speech_balloon: myunbin created PR review comment:
Add an all-zero helper for float and vector types.
:memo: fitzgen submitted PR review:
Thanks! One last question below about the new
all_zerohelper
:speech_balloon: fitzgen created PR review comment:
Is it more efficient to load zeros by splatting than via loads from the constant pool?
It seems like we don't have any terms in the mid-end's prelude for working with
ir::Constants, but they would be easy to add if necessary.But if splatting is expected to be more efficient, then we should add a comment to that effect here.
:memo: myunbin submitted PR review.
:speech_balloon: myunbin created PR review comment:
@fitzgen
I did not use splatting for efficiency reasons, but because there is an existing rule that rewrites constant splats to
vconstforvec128(I don't think there is an equivalent rule forvec64).I believe adding
ir::Constanthelpers may be a better approach.Thanks!
:memo: fitzgen submitted PR review.
:speech_balloon: fitzgen created PR review comment:
(sorry for the delayed response, just got back from vacation)
Okay, I'll go ahead and enqueue this PR for merging, but regarding this:
I believe adding
ir::Constanthelpers may be a better approach.Would you be interested in investigating adding
ir::Constanthelpers and improving these rules in a follow up PR?
:thumbs_up: fitzgen submitted PR review.
fitzgen added PR #13850 Cranelift: Add(and modify) simplification rules to the merge queue.
:check: fitzgen merged PR #13850.
fitzgen removed PR #13850 Cranelift: Add(and modify) simplification rules from the merge queue.
:memo: myunbin submitted PR review.
:speech_balloon: myunbin created PR review comment:
Sure. I’ll take a look and add some
ir::Constanthelpers.
Last updated: Jul 29 2026 at 05:03 UTC