This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][VP] Add RVV codegen for [nX]vXi1 vp.select
ClosedPublic

Authored by victor-eds on Dec 10 2021, 11:42 AM.

Details

Summary

Expand [nX]vXi1 vp.select the same way as [nX]vXi1 vselect.

Diff Detail

Event Timeline

victor-eds created this revision.Dec 10 2021, 11:42 AM
victor-eds requested review of this revision.Dec 10 2021, 11:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2021, 11:42 AM
victor-eds edited reviewers, added: rogfer01; removed: efocht.Dec 14 2021, 12:31 AM
frasercrmck added a subscriber: RKSimon.
frasercrmck added inline comments.
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
1204

nit: Implement

1211

nit: EVL would be a more appropriate name, I think.

1216

nit: VP_XOR

1221

The following expansion is only correct under certain conditions: when the vselect condition and operand types are identically-sized integer vectors and when the mask is -1/0. See the original ExpandVSELECT for that.

Since we don't have an in-tree test case for anything other than expanding [nx]vXi1 VSELECT maybe it's sufficient for now to resort to UnrollVectorOp whenever the operand types aren't i1 vectors? UnrollVectorOp will no doubt fail for VP_SELECT right now, but we wouldn't be making anything worse.

Not sure: any thoughts @craig.topper? @RKSimon?

craig.topper added inline comments.Dec 17 2021, 9:37 AM
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
1204

This code only works if Mask's VT is the same as Op1/Op2 VT but that isn't guaranteed in general. We should call UnrollVectorOp for that just like ExpandVSELECT.

1221

I think I'm fine with calling Unroll if it isn't an nxvXi1 vector.

1222

Why a lamdba? Can't we just do

SDValue Ones = DAG.getAllOnesConstant(DL, VT);
SDValue NotMask = DAG.getNode(ISD::VP_XOR, DL, VT, Mask, Ones, Ones, Length);

Arguably that should be

DAG.getNode(ISD::VP_XOR, DL, VT, Mask, Ones, Mask, Length);

so the XOR has the same mask as the other ops.

Unroll op if the operands are not i1 vectors

victor-eds marked 7 inline comments as done.Dec 23 2021, 12:31 AM
This revision is now accepted and ready to land.Dec 24 2021, 8:29 AM

@craig.topper Can you please land this one for me? I tried to fix the pipeline by rebasing (hence the last diff), but it appears to be broken in main. I'll ask for commit access after this patch has been landed so that I don't need to ask you for it again. Thanks!

This revision was landed with ongoing or failed builds.Jan 2 2022, 11:16 PM
This revision was automatically updated to reflect the committed changes.