Stream: git-wasmtime

Topic: wasmtime / PR #12369 x64/aarch64: Remove recursion in fma...


view this post on Zulip Wasmtime GitHub notifications bot (Jan 18 2026 at 21:05):

alexcrichton opened PR #12369 from alexcrichton:fix-lower-fmla to bytecodealliance:main:

This commit refactors the x64 and aarch64 backends to no longer have recursion in the lowering of the fma CLIF instruction. These internally used fneg of an operand to switch back-and-forth between two native instructions, but that meant that unoptimized code could control recursion in the backend. The rules additionally weren't necessary since egraphs already optimize away extra fneg nodes meaning that the backends just need to match a single layer.

I found that I couldn't actually trigger stack overflow in a release build of Wasmtime for either backend. Upon looking at the generated machine code it looks like the constructors here were tail-recursive which prevented the stack overflow. Nonetheless there's no need for this recursion to exist, and in debug mode it definitely blows the stack.

The two backends are now more similar in structure than they were before, but the meaning of similarly-named functions is different between the two backends to match the native behavior of the generated instructions.

Closes #12368

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jan 18 2026 at 21:05):

alexcrichton requested cfallin for a review on PR #12369.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 18 2026 at 21:05):

alexcrichton requested wasmtime-compiler-reviewers for a review on PR #12369.

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

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

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

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

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

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

view this post on Zulip Wasmtime GitHub notifications bot (Jan 20 2026 at 00:39):

cfallin submitted PR review:

Thanks!

Could we add ISA tests that have a bunch of nested fnegs, and show compilation with and without opts enabled (similar to #12333)?

view this post on Zulip Wasmtime GitHub notifications bot (Jan 20 2026 at 00:39):

cfallin created PR review comment:

This is still breaking my brain somewhat -- "then subtract" is ambigous (this reads like result = accum - (-(a*b))). Could we write the formula? E.g. result = -(a*b) - accum.

(likewise for others)

view this post on Zulip Wasmtime GitHub notifications bot (Jan 20 2026 at 17:56):

alexcrichton updated PR #12369.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 20 2026 at 17:56):

alexcrichton updated PR #12369.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 20 2026 at 17:57):

alexcrichton has enabled auto merge for PR #12369.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 20 2026 at 18:19):

alexcrichton added PR #12369 x64/aarch64: Remove recursion in fma backend rules to the merge queue.

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

github-merge-queue[bot] removed PR #12369 x64/aarch64: Remove recursion in fma backend rules from the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 20 2026 at 19:39):

alexcrichton added PR #12369 x64/aarch64: Remove recursion in fma backend rules to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 20 2026 at 20:02):

alexcrichton merged PR #12369.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 20 2026 at 20:02):

alexcrichton removed PR #12369 x64/aarch64: Remove recursion in fma backend rules from the merge queue.


Last updated: Jan 29 2026 at 13:25 UTC