myunbin opened PR #14327 from myunbin:add-rules-260914 to bytecodealliance:main:
Add new mid-end optimization rules:
x << (k & (B - 1)) ==> x << kx >>u (k & (B - 1)) ==> x >>u kx >>s (k & (B - 1)) ==> x >>s kuextend(x) <u uextend(y) ==> x <u yx %s P == 0 ==> (x & (P - 1)) == 0(constant power-of-two P > 0)(x >=s 0) & (x <s N) ==> x <u N(constant 0 < N < 2^(B - 1))x %u (1 << k) ==> x & ((1 << k) - 1)
myunbin requested alexcrichton for a review on PR #14327.
myunbin requested wasmtime-compiler-reviewers for a review on PR #14327.
:thumbs_up: alexcrichton submitted PR review:
Thanks!
@avanhatt or @mmcloughlin would y'all be able to help out with the CI failure?
ERROR #1147 cranelift/codegen/src/opts/icmp.isle line 554 expanding constructor 'i64_gt': no spec for term i64_gt ERROR #1148 cranelift/codegen/src/opts/icmp.isle line 562 expanding constructor 'i64_trailing_zeros': no spec for term i64_trailing_zeros
:speech_balloon: alexcrichton created PR review comment:
This comment may be a copy/paste? (or maybe a forgotten inclusion?)
github-actions[bot] added the label cranelift on PR #14327.
github-actions[bot] added the label isle on PR #14327.
github-actions[bot] commented on PR #14327:
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 <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
avanhatt commented on PR #14327:
It looks like two ISLE external terms (
i64_gt&i64_trailing_zeros), while not new in this PR, need specs because these new rules are the first to use them for in-scope features.@myunbin would you be willing to try adding the new specs by following the examples in
/Users/avh/research/wasmtime/cranelift/codegen/src/spec/opt.isle?For example, similar to line 452:
(spec (i64_gt_eq x y) (provide (= result (bvsge x y))))You can add:
(spec (i64_eq x y) (provide (= result (bvsgt x y))))
avanhatt edited a comment on PR #14327:
It looks like two ISLE external terms (
i64_gt&i64_trailing_zeros), while not new in this PR, need specs because these new rules are the first to use them for in-scope features.@myunbin would you be willing to try adding the new specs by following the examples in
/Users/avh/research/wasmtime/cranelift/codegen/src/spec/opt.isle?For example, similar to line 452:
(spec (i64_gt_eq x y) (provide (= result (bvsge x y))))You can add:
(spec (i64_gt x y) (provide (= result (bvsgt x y))))
myunbin updated PR #14327.
myunbin commented on PR #14327:
Hi @avanhatt, I just added some missing helper specs:
i64_gti64_trailing_zerosu32_lti64_wrapping_subu64_is_power_of_twoThanks!
myunbin edited a comment on PR #14327:
@avanhatt Hi, I just added some missing helper specs:
i64_gti64_trailing_zerosu32_lti64_wrapping_subu64_is_power_of_twoThanks!
myunbin edited a comment on PR #14327:
@avanhatt Hi, I've just added some missing helper specs:
i64_gti64_trailing_zerosu32_lti64_wrapping_subu64_is_power_of_twoThanks!
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
To confirm, is this a rule you wanted to add in this PR? Or was this a stray copy/paste?
I don't see anything w/
sremin the below rules and I'd otherwise expect these rules to be inarithmetic.islelike the similar rule added in this PR, so I wanted to confirm.
myunbin updated PR #14327.
:memo: myunbin submitted PR review.
:speech_balloon: myunbin created PR review comment:
Sorry for the delay.
I mistakenly added that comment.
I've pushed an update erasing it.Thanks!
alexcrichton added PR #14327 Cranelift: add mid-end opt rules to the merge queue.
:check: alexcrichton merged PR #14327.
alexcrichton removed PR #14327 Cranelift: add mid-end opt rules from the merge queue.
Last updated: Sep 20 2026 at 18:08 UTC