This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Transform VMERGE_VVM_<LMUL>_TU with all ones mask to VADD_VI_<LMUL>_TU.
ClosedPublic

Authored by fakepaper56 on Sep 3 2022, 6:25 AM.

Details

Summary

The transformation is benefit because vmerge.vvm always needs mask operand but
vadd.vi may not.

Diff Detail

Event Timeline

fakepaper56 created this revision.Sep 3 2022, 6:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 3 2022, 6:25 AM
fakepaper56 requested review of this revision.Sep 3 2022, 6:25 AM
fakepaper56 added inline comments.Sep 3 2022, 6:34 AM
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
2511

Do we have an instruction that mask operand is not v0? I am confused by the condition.

craig.topper added inline comments.Sep 4 2022, 8:14 PM
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
2509

use -> uses?

2710

decrase -> decrease

2713

Should we move this check and useAllOnesMask up to the caller? They are common to performVMergeToVAdd and performCombineVMergeAndVOps.

Address Craig's comment and -verify-machineinstrs into test case.

fakepaper56 marked 2 inline comments as done.Sep 4 2022, 11:11 PM
fakepaper56 added inline comments.
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
2509

Done.

2710

Done.

2713

Good point. Done.

kito-cheng added inline comments.Sep 4 2022, 11:15 PM
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
2511

We *might* allow mask hold other than v0 register in future vector extension, so having this checking should be harmless, and could catch unexpected case in future.

fakepaper56 marked 2 inline comments as done.Sep 5 2022, 12:12 AM
fakepaper56 added inline comments.
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
2511

Thank your explanation.

I still moved useAllOnesMask into performVMergeToVAdd, since only
performVMergeToVAdd needs to call useAllOnesMask.

I still moved useAllOnesMask into performVMergeToVAdd, since only
performVMergeToVAdd needs to call useAllOnesMask.

Doesn't doPeepholeMaskedRVV call usesAllOnesMask on line 2555?

fakepaper56 added a comment.EditedSep 5 2022, 1:16 AM

I still moved useAllOnesMask into performVMergeToVAdd, since only
performVMergeToVAdd needs to call useAllOnesMask.

Doesn't doPeepholeMaskedRVV call usesAllOnesMask on line 2555?

But the new function performCombineVMergeAndVOps also serves vmerge.vvm without all ones mask.

This revision is now accepted and ready to land.Sep 13 2022, 1:47 PM