Add support for x86 FMA intrinsics#27183
Open
fanchenkong1 wants to merge 1 commit into
Open
Conversation
Implement all 32 FMA intrinsics in a new <fmaintrin.h>, wired into <immintrin.h> and gated on __FMA__. Pass -msimd128 -mfma to enable. Each intrinsic has a dual implementation: - With -mrelaxed-simd, it lowers to Wasm relaxed SIMD fused multiply-add (relaxed_madd / relaxed_nmadd). - With -msimd128 only, it is emulated with separate multiply and add/subtract. The 256-bit AVX variants are emulated by applying the 128-bit operation to each half of the vector. Compiler wiring adds -mfma to the SIMD Intel feature tower and defines __FMA__ accordingly. Documentation is added to the SIMD porting guide and ChangeLog. Tests: - test/sse/test_fma.cpp: self-contained correctness checks covering all 32 intrinsics, run with the emulated path. - test/sse/test_fma_relaxed.cpp: exhaustive comparison against native x86, run with relaxed SIMD.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change follows #23035. It adds support for compiling x86 FMA intrinsics to WebAssembly. All 32 FMA intrinsics are implemented in a new <fmaintrin.h>, wired into <immintrin.h> and gated on
__FMA__. Enable with -msimd128 -mfma.Each intrinsic has a dual implementation:
The 256-bit AVX variants are emulated by applying the 128-bit operation to each half of the vector. Compiler wiring adds -mfma to the SIMD Intel feature tower and defines
__FMA__.Tests: