summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
AgeCommit message (Collapse)Author
2025-11-18[WebAssembly] Add patterns for extadd pairwise (#167960)Jasmine Tang
Add a few patterns for extadd pairwise.
2025-10-23[WebAssembly] [Codegen] Add pattern for relaxed min max from pmin/pmax-based ↵Jasmine Tang
patterns over v4f32 and v2f64 (#164486) Related to https://github.com/llvm/llvm-project/issues/55932
2025-10-22[WebAssembly] [Codegen] Add pattern for relaxed min max from ↵Jasmine Tang
fminimum/fmaximum over v4f32 and v2f64 (#162948) Related to #55932
2025-10-20[WebAssembly] Avoid dot for v16i8 partial_smla (#163796)Sam Parker
The sequence is shorter, by two extend operations, if we just use extmul and extadd_pairwise.
2025-10-16[WebAssembly] [Codegen] Add patterns for relaxed dot (#163266)Jasmine Tang
The pattern I added for `relaxed dot` similar to normal dot @ https://github.com/llvm/llvm-project/pull/151775. For `relaxed dot add`, i noticed that in the proposal the portion of dot implementation is similar to `relaxed dot`, so I think we can add a pattern where after we do relaxed dot and do extadd pairwise, we can do `relaxed dot add`. One current obstacles is I don't think there is any pattern to singly create a extadd pairwise from other instructions so the `relaxed dot add` pattern would not cover a wide range of instructions. related to https://github.com/llvm/llvm-project/issues/55932
2025-10-16[WebAssembly] Partial SMLA with relaxed dot (#163529)Sam Parker
Lower v16i8 to v4i32 partial_smla to relaxed_dot_add. I'm still unsure whether we could/should take advantage of the unknown signedness of the rhs, and also lower the partial_sumla operation too.
2025-10-13[WebAssembly] Add extra pattern for dot (#151775)Jasmine Tang
Fixes https://github.com/llvm/llvm-project/issues/50154
2025-10-13Wasm fmuladd relaxed (#163177)Sam Parker
Reland #161355, after fixing up the cross-projects-tests for the wasm simd intrinsics. Original commit message: Lower v4f32 and v2f64 fmuladd calls to relaxed_madd instructions. If we have FP16, then lower v8f16 fmuladds to FMA. I've introduced an ISD node for fmuladd to maintain the rounding ambiguity through legalization / combine / isel.
2025-10-13Revert "[WebAssembly] Lower fmuladd to madd and nmadd" (#163171)Sam Parker
Reverts llvm/llvm-project#161355 Looks like I've broken some intrinsic code generation.
2025-10-13[WebAssembly] Lower fmuladd to madd and nmadd (#161355)Sam Parker
Lower v4f32 and v2f64 fmuladd calls to relaxed_madd instructions. If we have FP16, then lower v8f16 fmuladds to FMA. I've introduced an ISD node for fmuladd to maintain the rounding ambiguity through legalization / combine / isel.
2025-10-08[WebAssembly] recognize saturating truncation (#155470)Folkert de Vries
fixes https://github.com/llvm/llvm-project/issues/153838 using the same approach as https://github.com/llvm/llvm-project/pull/155377 Recognize a manual saturating truncation and select the corresponding instruction. This is useful in general, but came up specifically in https://github.com/rust-lang/stdarch because it will allow us to drop more target-specific intrinsics in favor of cross-platform ones.
2025-09-30[WebAssembly] Use partial_reduce_mla ISD nodes (#161184)Sam Parker
Addresssing issue #160847. Move away from combining the intrinsic call and instead lower the ISD nodes, using tablegen for pattern matching.
2025-09-12[WebAssembly] Support partial-reduce accumulator (#158060)Sam Parker
We currently only support partial.reduce.add in the case where we are performing a multiply-accumulate. Now add support for any partial reduction where the input is being extended, where we can take advantage of extadd_pairwise.
2025-09-10[WebAssembly] extadd_pairwise for PartialReduce (#157669)Sam Parker
Avoid using extends, and adding the high and low half and use extadd_pairwise instead.
2025-08-22[WebAssembly] Add support for avgr_u in loops (#153252)Jasmine Tang
Fixes https://github.com/llvm/llvm-project/issues/150550. With the test case ``` void f(unsigned char *x, unsigned char *y, int n) { // should have been vectorized into avgr_u instead of seperated vectorized add and logical right shift for (int i = 0; i < n; i++) x[i] = (x[i] + y[i] + 1) / 2; } ``` the backend failed to recognize that this can be reduced to avgr_u since the loop vectorizer doesn't transform into the existing pattern in tablegen. This PR sets AVGCEIL_U as legal for v8i16 and v16i8 and selects it to avgr_u in the tablegen file.
2025-07-28[WebAssembly] Add pattern for relaxed nmadd (#150684)Jasmine Tang
Following footstep of https://github.com/llvm/llvm-project/pull/147487 (support for madd), this PR adds support for nmadd. https://github.com/llvm/llvm-project/issues/55932 tracks this
2025-07-15[WebAssembly] Add patterns for relaxed madd (#147487)jjasmine
[WebAssembly] Fold fadd contract (fmul contract) to relaxed madd w/ -mattr=+simd128,+relaxed-simd Fixes #121311 - Precommit test for #121311 - Fold fadd contract (fmul contract) to relaxed madd w/ -mattr=+simd128,+relaxed-simd - Move PatFrag of fadd_contract in ARM.td and WebAssembly.td to TargetSelectionDAG.td for reuse of pattern
2025-02-25[WebAssembly] Support shuffle for F16x8 vectors. (#127857)Brendan Dahl
2025-02-03[WebAssembly] Autovec support for dot (#123207)Sam Parker
Enable the use of partial.reduce.add that we can lower to dot or a tree of (add (extmul_low_u, extmul_high_u)) for the unsigned case. We support both v8i16 and v16i8 inputs.
2024-10-18Fix typo "instrinsic" (#112899)Jay Foad
2024-09-22[clang][wasm] Replace the target integer sub saturate intrinsics with the ↵Simon Pilgrim
equivalent generic `__builtin_elementwise_sub_sat` intrinsics (#109405) Remove the Intrinsic::wasm_sub_sat_signed/wasm_sub_sat_unsigned entries and just use sub_sat_s/sub_sat_u directly
2024-09-11[WebAssembly] Fix lane index size for f16x8 extract_lane. (#108118)Brendan Dahl
2024-09-11[WebAssembly] Add load and store patterns for V8F16. (#108119)Brendan Dahl
2024-08-30[WebAssembly] Update FP16 opcodes to match current spec. (#106759)Brendan Dahl
https://github.com/WebAssembly/half-precision/blob/f267a3d54432e5723dcc13ad4530c3581a0cc4b3/proposals/half-precision/Overview.md#binary-format
2024-08-30[WebAssembly] Add intrinsics to wasm_simd128.h for all FP16 instructions ↵Brendan Dahl
(#106465) Getting this to work required a few additional changes: - Add builtins for any instructions that can't be done with plain C currently. - Add support for the saturating version of fp_to_<s,i>_I16x8. Other vector sizes supported this already. - Support bitcast of f16x8 to v128. Needed to return a __f16x8 as v128_t.
2024-08-22[WebAssembly] Change half-precision feature name to fp16. (#105434)Brendan Dahl
This better aligns with how the feature is being referred to and what runtimes (V8) are calling it.
2024-08-02[WebAssembly] load_zero to initialise build_vector (#100610)Sam Parker
Instead of splatting a single lane, to initialise a build_vector, lower to scalar_to_vector which can be selected to load_zero. Also add load_zero and load_lane patterns for f32x4 and f64x2.
2024-07-24[WebAssembly] Implement f16x8.replace_lane instruction. (#99388)Brendan Dahl
Use a builtin and intrinsic until half types are better supported for instruction selection.
2024-07-24[WebAssembly] Ofast pmin/pmax pattern matchers (#100107)Sam Parker
With fast-math, the ordered setcc nodes are converted to setcc nodes which do not care about NaNs, so add patterns that use setlt, setle, setgt and setge.
2024-06-25[WebAssembly] Implement trunc_sat and convert instructions for f16x8. (#95180)Brendan Dahl
These instructions can be generated using regular LL intrinsics. Specified at: https://github.com/WebAssembly/half-precision/blob/29a9b9462c9285d4ccc1a5dc39214ddfd1892658/proposals/half-precision/Overview.md
2024-06-11[WebAssembly] Implement f16x8 madd and nmadd instructions. (#95151)Brendan Dahl
Implemented with intrinsics and builtins. Specified at: https://github.com/WebAssembly/half-precision/blob/main/proposals/half-precision/Overview.md
2024-06-04[WebAssembly] Implement all f16x8 unary instructions. (#94063)Brendan Dahl
All of these instructions can be generated using regular LL intrinsics. Specified at: https://github.com/WebAssembly/half-precision/blob/29a9b9462c9285d4ccc1a5dc39214ddfd1892658/proposals/half-precision/Overview.md
2024-05-30[WebAssembly] Implement all f16x8 relation instructions. (#93751)Brendan Dahl
All of these instructions can be generated using regular LL instructions. Specified at: https://github.com/WebAssembly/half-precision/blob/29a9b9462c9285d4ccc1a5dc39214ddfd1892658/proposals/half-precision/Overview.md
2024-05-28[WebAssembly] Implement all f16x8 binary instructions. (#93360)Brendan Dahl
This reuses most of the code that was created for f32x4 and f64x2 binary instructions and tries to follow how they were implemented. add/sub/mul/div - use regular LL instructions min/max - use the minimum/maximum intrinsic, and also have builtins pmin/pmax - use the wasm.pmax/pmin intrinsics and also have builtins Specified at: https://github.com/WebAssembly/half-precision/blob/29a9b9462c9285d4ccc1a5dc39214ddfd1892658/proposals/half-precision/Overview.md
2024-05-24[WebAssembly] Implement prototype f16x8.extract_lane instruction. (#93272)Brendan Dahl
Specified at: https://github.com/WebAssembly/half-precision/blob/29a9b9462c9285d4ccc1a5dc39214ddfd1892658/proposals/half-precision/Overview.md Note: the current spec has f16x8.extract_lane as opcode 0x124, but this is incorrect and will be changed to 0x121 soon.
2024-05-23[WebAssembly] Implement prototype f16x8.splat instruction. (#93228)Brendan Dahl
Adds a builtin and intrinsic for the f16x8.splat instruction. Specified at: https://github.com/WebAssembly/half-precision/blob/29a9b9462c9285d4ccc1a5dc39214ddfd1892658/proposals/half-precision/Overview.md Note: the current spec has f16x8.splat as opcode 0x123, but this is incorrect and will be changed to 0x120 soon.
2024-03-20[WebAssembly] Select BUILD_VECTOR with large unsigned lane values (#85880)Thomas Lively
Previously we expected lane constants to be in the range of signed values for each lane size, but the included test case produced large unsigned values that fall outside that range. Allow instruction selection to proceed in this case rather than failing. Fixes #63817.
2023-06-23[WebAssembly] Add lowering for llvm.rint and llvm.roundevenxortoast
WebAssembly doesn't expose inexact exceptions, so frint can be mapped to fnearbyint. Likewise, WebAssembly always rounds ties-to-even, so froundeven can be mapped to fnearbyint. Differential Revision: https://reviews.llvm.org/D153451
2023-05-05[WebAssembly] Mark @llvm.wasm.shuffle lane indices as immediatesThomas Lively
This intrinsic is meant to lower directly to the i8x16.shuffle instruction, which takes its lane index arguments as immmediates. The ISel for the intrinsic assumed that the lane index arguments were constants, so bitcode that "incorrectly" used this intrinsic with non-immediate arguments caused an assertion failure in the backend. Avoid the crash by defining the lane index arguments to be immediates, matching the underlying instruction. Update ISel accordingly. This change means that the bitcode that previously caused a crash will now fail to validate. Fixes #55559. Reviewed By: dschuff Differential Revision: https://reviews.llvm.org/D149898
2023-05-03[WebAssembly] Remove incorrect result from wasm64 store_lane instructionsThomas Lively
The wasm64 versions of the v128.storeX_lane instructions was incorrectly defined as returning a v128 value, which resulted in spurious drop instructions being emitted and causing validation to fail. This was not caught earlier because wasm64 has been experimental and not well tested. Update the relevant test file to test both wasm32 and wasm64. Fixes #62443. Differential Revision: https://reviews.llvm.org/D149780
2023-02-22[WebAssembly] pmin/pmax fixesSamuel Parker
Reverse the operand ordering to ? rhs : lhs. Differential Revision: https://reviews.llvm.org/D144466
2023-02-22[WebAssembly] Add more combine pattern for vector shiftJun Ma
After change with D144169, the codegen generates redundant instructions like and and wrap. This fixes it. Differential Revision: https://reviews.llvm.org/D144360
2023-02-10[WebAssembly] Additional patterns for pmin/paxSamuel Parker
Each operation was missing their inverted condition using olt or ogt. Also, as we don't need to discern +/-0, I think we should also be able to use ole and oge. Differential Revision: https://reviews.llvm.org/D143581
2023-01-04[WebAssembly] Replace LOAD_SPLAT with SPLAT_VECTORLuke Lau
Splats were selected by matching on uses of `build_vector` with identical elements, but a while back a target independent node for vector splatting was added. This removes the WebAssembly specific LOAD_SPLAT intrinsic, and instead makes SPLAT_VECTOR legal and adds patterns for splat loads. Differential Revision: https://reviews.llvm.org/D139871
2022-12-15[WebAssembly] Use ComplexPattern on remaining memory instructionsLuke Lau
This continues the refactoring work of selecting offset + address operands with the AddrOpsN pattern, previously called LoadOpsN. This is not an NFC, since constant addresses are now folded into the offset in more places for v128.storeN_lane. Differential Revision: https://reviews.llvm.org/D139950
2022-12-14[WebAssembly][NFC] Add ComplexPattern for loadsLuke Lau
This refactors out the offset and address operand pattern matching into a ComplexPattern, so that one pattern fragment can match the dynamic and static (offset) addresses in all possible positions. Split out from D139530, which also contained an improvement to global address folding. Differential Revision: https://reviews.llvm.org/D139631
2022-11-21[WebAssembly] Update relaxed-simd instruction namesThomas Lively
Including builtin and intrinsic names. These should be the final names for the proposal. https://github.com/WebAssembly/relaxed-simd/blob/main/proposals/relaxed-simd/Overview.md Reviewed By: aheejin, maratyszcza Differential Revision: https://reviews.llvm.org/D138249
2022-09-21[WebAssembly] Improve codegen for loading scalars from memory to v128Fanchen Kong
Use load32_zero instead of load32_splat to load the low 32 bits from memory to v128. Test cases are added to cover this change. Reviewed By: tlively Differential Revision: https://reviews.llvm.org/D134257
2022-09-08[WebAssembly] Prototype `f32x4.relaxed_dot_bf16x8_add_f32`Thomas Lively
As proposed in https://github.com/WebAssembly/relaxed-simd/issues/77. Only an LLVM intrinsic and a clang builtin are implemented. Since there is no bfloat16 type, use u16 to represent the bfloats in the builtin function arguments. Differential Revision: https://reviews.llvm.org/D133428
2022-08-03[WebAssembly] Improve codegen for v128.bitselectThomas Lively
Add patterns selecting ((v1 ^ v2) & c) ^ v2 and ((v1 ^ v2) & ~c) ^ v2 to v128.bitselect. Resolves #56827. Reviewed By: aheejin Differential Revision: https://reviews.llvm.org/D131131