Stream: git-wasmtime

Topic: wasmtime / PR #14226 Cranelift arithmetic mid-end optimiz...


view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2026 at 18:22):

yagehu opened PR #14226 from yagehu:opt to bytecodealliance:main:

This commit adds these arithmetic mid-end optimization rules and their commutative variants. I've also added at least one filetest for each rule.

(x & y) - (x | y)     --> -(x ^ y)
(x ^ y) - (x | y)     --> -(x & y)
(x ^ y) + 2 * (x & y) --> x + y
(x - y) + (y - x)     --> 0

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2026 at 18:22):

yagehu requested wasmtime-compiler-reviewers for a review on PR #14226.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2026 at 18:22):

yagehu requested cfallin for a review on PR #14226.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2026 at 18:23):

yagehu edited PR #14226:

This commit adds these arithmetic mid-end optimization rules and their commutative variants. I've also added at least one filetest for each rule that failed to optimize in main.

(x & y) - (x | y)     --> -(x ^ y)
(x ^ y) - (x | y)     --> -(x & y)
(x ^ y) + 2 * (x & y) --> x + y
(x - y) + (y - x)     --> 0

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2026 at 20:41):

:thumbs_up: cfallin submitted PR review:

LGTM, thanks!

As an aside: rules like (x ^ y) + 2 * (x & y) --> x + y make my head hurt to think about (that's a full adder, I guess?? XOR for the sum and AND for the carry, shifted up one bit?) but now that we have formal verification in CI, we get to see this Just Work(tm) (logs:

============================= Verification summary ============================
Total expansions:    1377
In scope expansions: 1096
Type instantiations: 5370
Applicable:          5356
Verification passed: 5356
Verification failed: 0
Verification unknown: 0
===============================================================================
========================== Cache statistics ===========================
Mode:            read-write
Source:          cranelift/isle/veri/cache
Destination:     cranelift/isle/veri/cache.rebuild
Hits:            10626 (99.1%)
Misses:          100 (0.9%)
New entries:     100
Retained:        10562
Source entries:  12128
Dropped (unused):1566

or in other words, everything here verifies, and we have some new entries in the cache ("New entries: 100") meaning something new did actually get processed. Very cool! (cc @avanhatt @mmcloughlin)

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2026 at 20:41):

:thumbs_up: cfallin submitted PR review:

LGTM, thanks!

As an aside: rules like (x ^ y) + 2 * (x & y) --> x + y make my head hurt to think about (that's a full adder, I guess?? XOR for the sum and AND for the carry, shifted up one bit?) but now that we have formal verification in CI, we get to see this Just Work(tm) (logs):

============================= Verification summary ============================
Total expansions:    1377
In scope expansions: 1096
Type instantiations: 5370
Applicable:          5356
Verification passed: 5356
Verification failed: 0
Verification unknown: 0
===============================================================================
========================== Cache statistics ===========================
Mode:            read-write
Source:          cranelift/isle/veri/cache
Destination:     cranelift/isle/veri/cache.rebuild
Hits:            10626 (99.1%)
Misses:          100 (0.9%)
New entries:     100
Retained:        10562
Source entries:  12128
Dropped (unused):1566

or in other words, everything here verifies, and we have some new entries in the cache ("New entries: 100") meaning something new did actually get processed. Very cool! (cc @avanhatt @mmcloughlin)

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2026 at 20:42):

cfallin added PR #14226 Cranelift arithmetic mid-end optimization rules to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2026 at 21:09):

:check: cfallin merged PR #14226.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 28 2026 at 21:09):

cfallin removed PR #14226 Cranelift arithmetic mid-end optimization rules from the merge queue.


Last updated: Aug 30 2026 at 09:07 UTC