Stream: git-wasmtime

Topic: wasmtime / PR #13458 egraph: peer through `ireduce` in `b...


view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 20:12):

ggreif edited PR #13458.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 20:13):

ggreif edited PR #13458:

Extends #13343's simplify_skeleton fold so the existing
brif (ctz X) / brif (clz X) rules also fire when an ireduce
(i.e. i32.wrap_i64 at the wasm level) sits between the count and
the branch.

Why this matters: non-Rust frontends targeting wasm-EOP often emit
i64.ctz; i32.wrap_i64; br_if for boolean-context LSB tests. The
wrap is harmless (the count is in [0, 64]) but it currently blocks
the fold, so cranelift falls back to materializing the full count
before the branch. With this PR, the i64-wrap form lowers to the
same testq \$1, %rdx; je shape as the i32 case.

Test coverage mirrors the existing patterns:

Source pattern in the wild: Motoko/moc's EOP peephole
(motoko PR #6117)
emits exactly \`i64.ctz; i32.wrap_i64; br_if\` for
\`(value & 1) == 0\`-as-branch-condition.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 20:14):

ggreif edited PR #13458:

Extends #13343's simplify_skeleton fold so the existing
brif (ctz X) / brif (clz X) rules also fire when an ireduce
(i.e. i32.wrap_i64 at the wasm level) sits between the count and
the branch.

Why this matters: non-Rust frontends targeting wasm-EOP often emit
i64.ctz; i32.wrap_i64; br_if for boolean-context LSB tests. The
wrap is harmless (the count is in [0, 64]) but it currently blocks
the fold, so cranelift falls back to materializing the full count
before the branch. With this PR, the i64-wrap form lowers to the
same testq $1, %rdx; je shape as the i32 case.

Test coverage mirrors the existing patterns:

Source pattern in the wild: motoko/moc's EOP peephole
(motoko PR #6117)
emits exactly i64.ctz; i32.wrap_i64; br_if for
(value & 1) == 0-as-branch-condition.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 20:15):

ggreif edited PR #13458:

Extends #13343's simplify_skeleton fold so the existing
brif (ctz X) / brif (clz X) rules also fire when an ireduce
(i.e. i32.wrap_i64 at the wasm level) sits between the count and
the branch.

Why this matters: non-Rust frontends targeting wasm-EOP often emit
i64.ctz; i32.wrap_i64; br_if for boolean-context LSB tests. The
wrap is harmless (the count is in [0, 64]) but it currently blocks
the fold, so cranelift falls back to materializing the full count
before the branch. With this PR, the i64-wrap form lowers to the
same testq $1, %rdx; je shape as the i32 case.

Test coverage mirrors the existing patterns:

Source pattern in the wild: Motoko/moc's EOP peephole
(motoko PR #6117)
emits exactly i64.ctz; i32.wrap_i64; br_if for
(value & 1) == 0-as-branch-condition.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 21:19):

:speech_balloon: cfallin created PR review comment:

let's use lowercase bindings (here X -> x) -- no particular syntactic rules against uppercase but it's not our style.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 21:19):

:thumbs_up: cfallin submitted PR review:

Thanks! New rule looks good; just some style comments.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 21:19):

:speech_balloon: cfallin created PR review comment:

No need for the verbose comment here -- and we don't want to pollute the ruleset with discussion about particular use-cases ("motoko/moc's EOP peephole" etc) as that isn't needed to justify straightforward simplifications.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 21:19):

:speech_balloon: cfallin created PR review comment:

Likewise here, let's not pollute with comments about particular other projects' code emission patterns. Actually most of the other tests don't have comments justifying their existence (more tests are always fine!) so no need to add them here.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 22:23):

ggreif updated PR #13458.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 22:24):

ggreif edited PR #13458:

Extends #13343's simplify_skeleton fold so the existing
brif (ctz X) / brif (clz X) rules also fire when an ireduce
(i.e. i32.wrap_i64 at the wasm level) sits between the count and
the branch.

Why this matters: non-Rust frontends targeting wasm-EOP often emit
i64.ctz; i32.wrap_i64; br_if for boolean-context LSB tests. The
wrap is harmless (the count is in [0, 64]) but it currently blocks
the fold, so cranelift falls back to materializing the full count
before the branch. With this PR, the i64-wrap form lowers to the
same testq $1, %rdx; je shape as the i32 case.

Test coverage mirrors the existing patterns:

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 22:29):

ggreif edited PR #13458:

Extends #13343's simplify_skeleton fold so the existing
brif (ctz X) / brif (clz X) rules also fire when an ireduce
(i.e. i32.wrap_i64 at the wasm level) sits between the count and
the branch.

Why this matters: non-Rust frontends targeting wasm64 often emit
i64.ctz; i32.wrap_i64; br_if for boolean-context LSB tests. The
wrap is harmless (the count is in [0, 64]) but it currently blocks
the fold, so cranelift falls back to materializing the full count
before the branch. With this PR, the i64-wrap form lowers to the
same testq $1, %rdx; je shape as the i32 case.

Test coverage mirrors the existing patterns:

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 22:30):

ggreif edited PR #13458:

Extends #13343's simplify_skeleton fold so the existing
brif (ctz x) / brif (clz x) rules also fire when an ireduce
(i.e. i32.wrap_i64 at the wasm level) sits between the count and
the branch.

Why this matters: non-Rust frontends targeting wasm64 often emit
i64.ctz; i32.wrap_i64; br_if for boolean-context LSB tests. The
wrap is harmless (the count is in [0, 64]) but it currently blocks
the fold, so cranelift falls back to materializing the full count
before the branch. With this PR, the i64-wrap form lowers to the
same testq $1, %rdx; je shape as the i32 case.

Test coverage mirrors the existing patterns:

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 22:41):

ggreif edited PR #13458:

Extends #13343's simplify_skeleton fold so the existing
brif (ctz X) / brif (clz X) rules also fire when an ireduce
(i.e. i32.wrap_i64 at the wasm level) sits between the count and
the branch.

Why this matters: non-Rust frontends targeting wasm64 often emit
i64.ctz; i32.wrap_i64; br_if for boolean-context LSB tests. The
wrap is harmless (the count is in [0, 64]) but it currently blocks
the fold, so cranelift falls back to materializing the full count
before the branch. With this PR, the i64-wrap form lowers to the
same testq $1, %rdx; je shape as the i32 case.

Test coverage mirrors the existing patterns:

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 22:45):

:memo: ggreif submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 22:45):

:speech_balloon: ggreif created PR review comment:

I think I used line 466 as a precedent.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 22:47):

:speech_balloon: ggreif edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 22:48):

:memo: ggreif submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 22:48):

:speech_balloon: ggreif created PR review comment:

Comment minimised, but kept.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 22:51):

ggreif updated PR #13458.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 23:07):

:thumbs_up: cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 23:08):

cfallin added PR #13458 egraph: peer through ireduce in brif (ctz/clz) skeleton fold to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 23:32):

github-merge-queue[bot] removed PR #13458 egraph: peer through ireduce in brif (ctz/clz) skeleton fold from the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (May 22 2026 at 23:36):

cfallin added PR #13458 egraph: peer through ireduce in brif (ctz/clz) skeleton fold to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (May 23 2026 at 00:00):

:check: cfallin merged PR #13458.

view this post on Zulip Wasmtime GitHub notifications bot (May 23 2026 at 00:00):

cfallin removed PR #13458 egraph: peer through ireduce in brif (ctz/clz) skeleton fold from the merge queue.


Last updated: Jun 01 2026 at 09:49 UTC