[llvm] [VP][RISCV] Add llvm.experimental.vp.reverse. (PR #70405)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 31 03:02:56 PDT 2023
================
@@ -10223,6 +10231,141 @@ SDValue RISCVTargetLowering::lowerVPFPIntConvOp(SDValue Op,
return convertFromScalableVector(VT, Result, DAG, Subtarget);
}
+SDValue
+RISCVTargetLowering::lowerVPReverseExperimental(SDValue Op,
+ SelectionDAG &DAG) const {
+ SDLoc DL(Op);
+ MVT VT = Op.getSimpleValueType();
+ MVT XLenVT = Subtarget.getXLenVT();
+
+ SDValue Op1 = Op.getOperand(0);
+ SDValue Mask = Op.getOperand(1);
+ SDValue EVL = Op.getOperand(2);
+
+ MVT ContainerVT = VT;
+ if (VT.isFixedLengthVector()) {
+ ContainerVT = getContainerForFixedLengthVector(VT);
+ Op1 = convertToScalableVector(ContainerVT, Op1, DAG, Subtarget);
+ MVT MaskVT = getMaskTypeFor(ContainerVT);
+ Mask = convertToScalableVector(MaskVT, Mask, DAG, Subtarget);
+ }
+
+ MVT GatherVT = ContainerVT;
+ MVT IndicesVT = ContainerVT.changeVectorElementTypeToInteger();
+ // Check if we are working with mask vectors
+ bool IsMaskVector = ContainerVT.getVectorElementType() == MVT::i1;
+ if (IsMaskVector) {
+ switch(ContainerVT.getVectorElementCount().getKnownMinValue()) {
+ default: llvm_unreachable("Invalid factor size");
+ case 1: IndicesVT = MVT::i64; break;
+ case 2: IndicesVT = MVT::i32; break;
+ case 4: IndicesVT = MVT::i16; break;
+ case 8:
+ case 16:
+ case 32:
+ case 64: IndicesVT = MVT::i8; break;
+ }
+ GatherVT = IndicesVT = ContainerVT.changeVectorElementType(IndicesVT);
+
+ // Expand input operand
+ SDValue SplatOne = DAG.getNode(RISCVISD::VMV_V_X_VL, DL, IndicesVT,
+ DAG.getUNDEF(IndicesVT),
+ DAG.getConstant(1, DL, XLenVT), EVL);
+ SDValue SplatZero = DAG.getNode(RISCVISD::VMV_V_X_VL, DL, IndicesVT,
+ DAG.getUNDEF(IndicesVT),
+ DAG.getConstant(0, DL, XLenVT), EVL);
+ Op1 = DAG.getNode(RISCVISD::VSELECT_VL, DL, IndicesVT, Op1, SplatOne,
+ SplatZero, EVL);
+ }
+
+ unsigned EltSize = GatherVT.getScalarSizeInBits();
+ unsigned MinSize = GatherVT.getSizeInBits().getKnownMinValue();
+ unsigned MaxVLMAX = 0;
+ unsigned VectorBitsMax = Subtarget.getRealMaxVLen();
+ if (VectorBitsMax != 0)
----------------
lukel97 wrote:
When do we get a max VLEN of 0?
https://github.com/llvm/llvm-project/pull/70405
More information about the llvm-commits
mailing list