Skip to content

[LoongArch] Add codegen support for [X]VF{MSUB/NMADD/NMSUB}.{S/D} ins… #74819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,32 @@ def : Pat<(fma v8f32:$xj, v8f32:$xk, v8f32:$xa),
def : Pat<(fma v4f64:$xj, v4f64:$xk, v4f64:$xa),
(XVFMADD_D v4f64:$xj, v4f64:$xk, v4f64:$xa)>;

// XVFMSUB_{S/D}
def : Pat<(fma v8f32:$xj, v8f32:$xk, (fneg v8f32:$xa)),
(XVFMSUB_S v8f32:$xj, v8f32:$xk, v8f32:$xa)>;
def : Pat<(fma v4f64:$xj, v4f64:$xk, (fneg v4f64:$xa)),
(XVFMSUB_D v4f64:$xj, v4f64:$xk, v4f64:$xa)>;

// XVFNMADD_{S/D}
def : Pat<(fneg (fma v8f32:$xj, v8f32:$xk, v8f32:$xa)),
(XVFNMADD_S v8f32:$xj, v8f32:$xk, v8f32:$xa)>;
def : Pat<(fneg (fma v4f64:$xj, v4f64:$xk, v4f64:$xa)),
(XVFNMADD_D v4f64:$xj, v4f64:$xk, v4f64:$xa)>;
def : Pat<(fma_nsz (fneg v8f32:$xj), v8f32:$xk, (fneg v8f32:$xa)),
(XVFNMADD_S v8f32:$xj, v8f32:$xk, v8f32:$xa)>;
def : Pat<(fma_nsz (fneg v4f64:$xj), v4f64:$xk, (fneg v4f64:$xa)),
(XVFNMADD_D v4f64:$xj, v4f64:$xk, v4f64:$xa)>;

// XVFNMSUB_{S/D}
def : Pat<(fneg (fma v8f32:$xj, v8f32:$xk, (fneg v8f32:$xa))),
(XVFNMSUB_S v8f32:$xj, v8f32:$xk, v8f32:$xa)>;
def : Pat<(fneg (fma v4f64:$xj, v4f64:$xk, (fneg v4f64:$xa))),
(XVFNMSUB_D v4f64:$xj, v4f64:$xk, v4f64:$xa)>;
def : Pat<(fma_nsz (fneg v8f32:$xj), v8f32:$xk, v8f32:$xa),
(XVFNMSUB_S v8f32:$xj, v8f32:$xk, v8f32:$xa)>;
def : Pat<(fma_nsz (fneg v4f64:$xj), v4f64:$xk, v4f64:$xa),
(XVFNMSUB_D v4f64:$xj, v4f64:$xk, v4f64:$xa)>;

// XVFSQRT_{S/D}
defm : PatXrF<fsqrt, "XVFSQRT">;

Expand Down
26 changes: 26 additions & 0 deletions llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,32 @@ def : Pat<(fma v4f32:$vj, v4f32:$vk, v4f32:$va),
def : Pat<(fma v2f64:$vj, v2f64:$vk, v2f64:$va),
(VFMADD_D v2f64:$vj, v2f64:$vk, v2f64:$va)>;

// VFMSUB_{S/D}
def : Pat<(fma v4f32:$vj, v4f32:$vk, (fneg v4f32:$va)),
(VFMSUB_S v4f32:$vj, v4f32:$vk, v4f32:$va)>;
def : Pat<(fma v2f64:$vj, v2f64:$vk, (fneg v2f64:$va)),
(VFMSUB_D v2f64:$vj, v2f64:$vk, v2f64:$va)>;

// VFNMADD_{S/D}
def : Pat<(fneg (fma v4f32:$vj, v4f32:$vk, v4f32:$va)),
(VFNMADD_S v4f32:$vj, v4f32:$vk, v4f32:$va)>;
def : Pat<(fneg (fma v2f64:$vj, v2f64:$vk, v2f64:$va)),
(VFNMADD_D v2f64:$vj, v2f64:$vk, v2f64:$va)>;
def : Pat<(fma_nsz (fneg v4f32:$vj), v4f32:$vk, (fneg v4f32:$va)),
(VFNMADD_S v4f32:$vj, v4f32:$vk, v4f32:$va)>;
def : Pat<(fma_nsz (fneg v2f64:$vj), v2f64:$vk, (fneg v2f64:$va)),
(VFNMADD_D v2f64:$vj, v2f64:$vk, v2f64:$va)>;

// VFNMSUB_{S/D}
def : Pat<(fneg (fma v4f32:$vj, v4f32:$vk, (fneg v4f32:$va))),
(VFNMSUB_S v4f32:$vj, v4f32:$vk, v4f32:$va)>;
def : Pat<(fneg (fma v2f64:$vj, v2f64:$vk, (fneg v2f64:$va))),
(VFNMSUB_D v2f64:$vj, v2f64:$vk, v2f64:$va)>;
def : Pat<(fma_nsz (fneg v4f32:$vj), v4f32:$vk, v4f32:$va),
(VFNMSUB_S v4f32:$vj, v4f32:$vk, v4f32:$va)>;
def : Pat<(fma_nsz (fneg v2f64:$vj), v2f64:$vk, v2f64:$va),
(VFNMSUB_D v2f64:$vj, v2f64:$vk, v2f64:$va)>;

// VFSQRT_{S/D}
defm : PatVrF<fsqrt, "VFSQRT">;

Expand Down
Loading