Stream: git-wasmtime

Topic: wasmtime / PR #14717 Cranelift: x64: branch on flags for ...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2026 at 11:54):

vamsi3 opened PR #14717 from vamsi3:x64-overflow-flag-branches to bytecodealliance:main:

Closes #14716

Adds the x64 flag-branching rules for usub_overflow, sadd_overflow and ssub_overflow, matching what #14228 and #14254 did for uadd_overflow. A brif on the overflow result now jumps on the flags of the add/sub instead of going through setcc + test.

Each op gets the same two rules as uadd_overflow:

Up to 64 bits only, like uadd_overflow; i128 is unchanged. As with uadd_overflow, if the value is used before the branch, the branch is in another block, or the flags have several uses, the add/sub gets emitted again for the branch. This relies on #14324 so a sunk load isn't duplicated. aarch64 can follow separately.

Example (usub_overflow at i32, value used in the taken block), 42 -> 35 bytes:

 subl    %esi, %r8d
-setb    %r9b
-testb   %r9b, %r9b
-jne     0x21
+jb      0x1a

Tests:

No existing expectations changed.

I measured this in a compiler of mine where every integer add/sub is overflow-checked, on Cranelift 0.136 with the is_nonzero rules backported. Instruction counts over its 11 benchmarks went down 2.3% overall (fasta -12.4%, the rest 0 to -5%).

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2026 at 11:54):

vamsi3 requested cfallin for a review on PR #14717.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2026 at 11:54):

vamsi3 requested wasmtime-compiler-reviewers for a review on PR #14717.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2026 at 14:49):

github-actions[bot] added the label cranelift on PR #14717.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2026 at 14:49):

github-actions[bot] added the label cranelift:area:x64 on PR #14717.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:24):

:thumbs_up: cfallin submitted PR review:

Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:24):

cfallin added PR #14717 Cranelift: x64: branch on flags for usub_overflow, sadd_overflow and ssub_overflow to the merge queue

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:48):

:check: cfallin merged PR #14717.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:48):

cfallin removed PR #14717 Cranelift: x64: branch on flags for usub_overflow, sadd_overflow and ssub_overflow from the merge queue


Last updated: Oct 31 2026 at 23:03 UTC