Skip to content

Commit ed51908

Browse files
authored
[RISCV] Emit VP strided load in mgather combine. NFCI (#98112)
This combine is a duplication of the transform in RISCVGatherScatterLowering but at the SelectionDAG level, so similarly to #98111 we can replace the use of riscv_masked_strided_load with a VP strided load. Unlike #98111 we don't require #97800 or #97798 since it only operates on fixed vectors with a non-zero stride.
1 parent 2abe53a commit ed51908

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17062,15 +17062,16 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
1706217062
SDValue BasePtr = DAG.getNode(ISD::ADD, DL, PtrVT, MGN->getBasePtr(),
1706317063
DAG.getConstant(Addend, DL, PtrVT));
1706417064

17065-
SDVTList VTs = DAG.getVTList({VT, MVT::Other});
17066-
SDValue IntID =
17067-
DAG.getTargetConstant(Intrinsic::riscv_masked_strided_load, DL,
17068-
XLenVT);
17069-
SDValue Ops[] =
17070-
{MGN->getChain(), IntID, MGN->getPassThru(), BasePtr,
17071-
DAG.getConstant(StepNumerator, DL, XLenVT), MGN->getMask()};
17072-
return DAG.getMemIntrinsicNode(ISD::INTRINSIC_W_CHAIN, DL, VTs,
17073-
Ops, VT, MGN->getMemOperand());
17065+
SDValue EVL = DAG.getElementCount(DL, Subtarget.getXLenVT(),
17066+
VT.getVectorElementCount());
17067+
SDValue StridedLoad =
17068+
DAG.getStridedLoadVP(VT, DL, MGN->getChain(), BasePtr,
17069+
DAG.getConstant(StepNumerator, DL, XLenVT),
17070+
MGN->getMask(), EVL, MGN->getMemOperand());
17071+
SDValue VPSelect = DAG.getNode(ISD::VP_SELECT, DL, VT, MGN->getMask(),
17072+
StridedLoad, MGN->getPassThru(), EVL);
17073+
return DAG.getMergeValues({VPSelect, SDValue(StridedLoad.getNode(), 1)},
17074+
DL);
1707417075
}
1707517076
}
1707617077

0 commit comments

Comments
 (0)