alexcrichton opened PR #5846 from improve-fma
to main
:
The relaxed-simd proposal for WebAssembly adds a fused-multiply-add operation for
v128
types so I was poking around at Cranelift's existing support for itsfma
instruction. I was also poking around at the x86_64 ISA's offerings for the FMA operation and ended up with this PR that improves the lowering of thefma
instruction on the x64 backend in a number of ways:
A libcall-based fallback is now provided for
f32x4
andf64x2
types in preparation for eventual support of the relaxed-simd proposal. These encodings are horribly slow, but it's expected that if FMA semantics must be guaranteed then it's the best that can be done without thefma
feature. Otherwise it'll be up to producers (e.g. Wasmtime embedders) whether wasm-level FMA operations should be FMA or multiply-then-add.In addition to the existing
vfmadd213*
instructions opcodes were added forvfmadd132*
. The132
variant is selected based on which argument can have a sinkable load.Any argument in the
fma
CLIF instruction can now have asinkable_load
and it'll generate a single FMA instruction.All
vfnmadd*
opcodes were added as well. These are pattern-matched where one of the arguments to the CLIF instruction is anfneg
. I opted to not add a new CLIF instruction here since it seemed like pattern matching was easy enough but I'm also not intimately familiar with the semantics here so if that's the preferred approach I can do that too.<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
abrown submitted PR review.
alexcrichton updated PR #5846 from improve-fma
to main
.
alexcrichton has enabled auto merge for PR #5846.
alexcrichton merged PR #5846.
Last updated: Dec 23 2024 at 13:07 UTC