This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add isel patterns for vfmacc, vfnmacc, vfmsac and vfnmsac.
ClosedPublic

Authored by fakepaper56 on Oct 3 2022, 8:27 AM.

Details

Summary

The patch selects VSELECT_VL/VP_MERGE_VL that uses VF(N)M(ACC|SAC) as its
true operand and the adden of the true operand as its false operand.

Diff Detail

Event Timeline

fakepaper56 created this revision.Oct 3 2022, 8:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 3 2022, 8:27 AM
fakepaper56 requested review of this revision.Oct 3 2022, 8:27 AM
craig.topper added inline comments.Oct 3 2022, 4:15 PM
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
1418

What about the VFMSAC, etc.? You can do them in a separate patch if you want but please give a roadmap of other patches you're planning.

This is also valid for integer vmacc and vnmsac.

fakepaper56 added inline comments.Oct 3 2022, 7:24 PM
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
1418

Sure, I will add VFMSAC in this patch. And I will add another patch for vmccc and vnmsac.

fakepaper56 added inline comments.Oct 3 2022, 7:35 PM
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
1418

I think VPatFPMulAccVL_VV_VF could serve VFNMSAC but not VFMSAC, since VFMSAC uses negative of adden.

1418

Maybe I need to use a new opcode riscv_vfmadd_vl_oneuse to make sure the fma instruction is only used by vselect_vl or vp_merge_vl.

craig.topper added inline comments.Oct 3 2022, 9:23 PM
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
1418

Maybe I need to use a new opcode riscv_vfmadd_vl_oneuse to make sure the fma instruction is only used by vselect_vl or vp_merge_vl.

Yes

1418

I think it should still be valid for VFMSAC. The elements that are masked off or in the tail won't be negated. The other elements will be.

Add vfnmsac patterns and constarin the selected VFMADD/VFNMSAC should have exactly one user.
Is it OK that I plan to add VFNMADD/VFMSAC in a seperated patch?

Refine commit message.

fakepaper56 retitled this revision from [RISCV] Add patterns for vfmacc for vp.select/vp.merge and vp.fma. to [RISCV] Add isel patterns for vfmacc and vfnmsac..Oct 4 2022, 12:42 AM
fakepaper56 edited the summary of this revision. (Show Details)
fakepaper56 marked an inline comment as done.Oct 4 2022, 12:48 AM
fakepaper56 added inline comments.
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
1418

I think it should still be valid for VFMSAC. The elements that are masked off or in the tail won't be negated. The other elements will be.

Yeah, I got the idea. But I just express that VFMAC needs other patterns than VPatFPMulAccVL_VV_VF.

craig.topper added inline comments.Oct 4 2022, 1:07 AM
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
1418

Why does it need a different pattern?

fakepaper56 added inline comments.Oct 4 2022, 3:17 AM
llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
1418

Sorry, I found that I were wrong. I will add VFMSAC and VFNMADD in the revision.

Add patterns for vfmsac, vfnmacc.

fakepaper56 retitled this revision from [RISCV] Add isel patterns for vfmacc and vfnmsac. to [RISCV] Add isel patterns for vfmacc, vfnmacc, vfmsac and vfnmsac..Oct 4 2022, 5:30 AM
fakepaper56 edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Oct 4 2022, 9:11 AM
craig.topper added inline comments.Oct 6 2022, 10:38 AM
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vfnmsac-vp.ll
7 ↗(On Diff #465254)

These are scalable vector tests in a fixed vector file.

craig.topper added inline comments.Oct 6 2022, 11:09 AM
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vfnmsac-vp.ll
7 ↗(On Diff #465254)

Converted to fixed vector in dc2b8fb965d535cf3c7149b0e66db28b330c4c90