@@ -7012,6 +7012,7 @@ static unsigned getRISCVVLOp(SDValue Op) {
7012
7012
OP_CASE(FDIV)
7013
7013
OP_CASE(FNEG)
7014
7014
OP_CASE(FABS)
7015
+ OP_CASE(FCOPYSIGN)
7015
7016
OP_CASE(FSQRT)
7016
7017
OP_CASE(SMIN)
7017
7018
OP_CASE(SMAX)
@@ -7079,6 +7080,15 @@ static unsigned getRISCVVLOp(SDValue Op) {
7079
7080
if (Op.getSimpleValueType().getVectorElementType() == MVT::i1)
7080
7081
return RISCVISD::VMXOR_VL;
7081
7082
return RISCVISD::XOR_VL;
7083
+ case ISD::ANY_EXTEND:
7084
+ case ISD::ZERO_EXTEND:
7085
+ return RISCVISD::VZEXT_VL;
7086
+ case ISD::SIGN_EXTEND:
7087
+ return RISCVISD::VSEXT_VL;
7088
+ case ISD::SETCC:
7089
+ return RISCVISD::SETCC_VL;
7090
+ case ISD::VSELECT:
7091
+ return RISCVISD::VMERGE_VL;
7082
7092
case ISD::VP_SELECT:
7083
7093
case ISD::VP_MERGE:
7084
7094
return RISCVISD::VMERGE_VL;
@@ -7419,12 +7429,16 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
7419
7429
if (Op.getOperand(0).getValueType().isVector() &&
7420
7430
Op.getOperand(0).getValueType().getVectorElementType() == MVT::i1)
7421
7431
return lowerVectorMaskExt(Op, DAG, /*ExtVal*/ 1);
7422
- return lowerFixedLengthVectorExtendToRVV(Op, DAG, RISCVISD::VZEXT_VL);
7432
+ if (Op.getValueType().isScalableVector())
7433
+ return Op;
7434
+ return lowerToScalableOp(Op, DAG);
7423
7435
case ISD::SIGN_EXTEND:
7424
7436
if (Op.getOperand(0).getValueType().isVector() &&
7425
7437
Op.getOperand(0).getValueType().getVectorElementType() == MVT::i1)
7426
7438
return lowerVectorMaskExt(Op, DAG, /*ExtVal*/ -1);
7427
- return lowerFixedLengthVectorExtendToRVV(Op, DAG, RISCVISD::VSEXT_VL);
7439
+ if (Op.getValueType().isScalableVector())
7440
+ return Op;
7441
+ return lowerToScalableOp(Op, DAG);
7428
7442
case ISD::SPLAT_VECTOR_PARTS:
7429
7443
return lowerSPLAT_VECTOR_PARTS(Op, DAG);
7430
7444
case ISD::INSERT_VECTOR_ELT:
@@ -8166,7 +8180,7 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
8166
8180
if (isPromotedOpNeedingSplit(Op.getOperand(0), Subtarget))
8167
8181
return SplitVectorOp(Op, DAG);
8168
8182
8169
- return lowerFixedLengthVectorSetccToRVV (Op, DAG);
8183
+ return lowerToScalableOp (Op, DAG);
8170
8184
}
8171
8185
case ISD::ADD:
8172
8186
case ISD::SUB:
@@ -8182,6 +8196,7 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
8182
8196
case ISD::UREM:
8183
8197
case ISD::BSWAP:
8184
8198
case ISD::CTPOP:
8199
+ case ISD::VSELECT:
8185
8200
return lowerToScalableOp(Op, DAG);
8186
8201
case ISD::SHL:
8187
8202
case ISD::SRA:
@@ -8250,14 +8265,12 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
8250
8265
return lowerToScalableOp(Op, DAG);
8251
8266
assert(Op.getOpcode() != ISD::CTTZ);
8252
8267
return lowerCTLZ_CTTZ_ZERO_UNDEF(Op, DAG);
8253
- case ISD::VSELECT:
8254
- return lowerFixedLengthVectorSelectToRVV(Op, DAG);
8255
8268
case ISD::FCOPYSIGN:
8256
8269
if (Op.getValueType() == MVT::f16 || Op.getValueType() == MVT::bf16)
8257
8270
return lowerFCOPYSIGN(Op, DAG, Subtarget);
8258
8271
if (isPromotedOpNeedingSplit(Op, Subtarget))
8259
8272
return SplitVectorOp(Op, DAG);
8260
- return lowerFixedLengthVectorFCOPYSIGNToRVV (Op, DAG);
8273
+ return lowerToScalableOp (Op, DAG);
8261
8274
case ISD::STRICT_FADD:
8262
8275
case ISD::STRICT_FSUB:
8263
8276
case ISD::STRICT_FMUL:
@@ -9694,33 +9707,6 @@ SDValue RISCVTargetLowering::lowerVectorMaskExt(SDValue Op, SelectionDAG &DAG,
9694
9707
return convertFromScalableVector(VecVT, Select, DAG, Subtarget);
9695
9708
}
9696
9709
9697
- SDValue RISCVTargetLowering::lowerFixedLengthVectorExtendToRVV(
9698
- SDValue Op, SelectionDAG &DAG, unsigned ExtendOpc) const {
9699
- MVT ExtVT = Op.getSimpleValueType();
9700
- // Only custom-lower extensions from fixed-length vector types.
9701
- if (!ExtVT.isFixedLengthVector())
9702
- return Op;
9703
- MVT VT = Op.getOperand(0).getSimpleValueType();
9704
- // Grab the canonical container type for the extended type. Infer the smaller
9705
- // type from that to ensure the same number of vector elements, as we know
9706
- // the LMUL will be sufficient to hold the smaller type.
9707
- MVT ContainerExtVT = getContainerForFixedLengthVector(ExtVT);
9708
- // Get the extended container type manually to ensure the same number of
9709
- // vector elements between source and dest.
9710
- MVT ContainerVT = MVT::getVectorVT(VT.getVectorElementType(),
9711
- ContainerExtVT.getVectorElementCount());
9712
-
9713
- SDValue Op1 =
9714
- convertToScalableVector(ContainerVT, Op.getOperand(0), DAG, Subtarget);
9715
-
9716
- SDLoc DL(Op);
9717
- auto [Mask, VL] = getDefaultVLOps(VT, ContainerVT, DL, DAG, Subtarget);
9718
-
9719
- SDValue Ext = DAG.getNode(ExtendOpc, DL, ContainerExtVT, Op1, Mask, VL);
9720
-
9721
- return convertFromScalableVector(ExtVT, Ext, DAG, Subtarget);
9722
- }
9723
-
9724
9710
// Custom-lower truncations from vectors to mask vectors by using a mask and a
9725
9711
// setcc operation:
9726
9712
// (vXi1 = trunc vXiN vec) -> (vXi1 = setcc (and vec, 1), 0, ne)
@@ -12834,31 +12820,6 @@ SDValue RISCVTargetLowering::lowerVectorCompress(SDValue Op,
12834
12820
return Res;
12835
12821
}
12836
12822
12837
- SDValue
12838
- RISCVTargetLowering::lowerFixedLengthVectorSetccToRVV(SDValue Op,
12839
- SelectionDAG &DAG) const {
12840
- MVT InVT = Op.getOperand(0).getSimpleValueType();
12841
- MVT ContainerVT = getContainerForFixedLengthVector(InVT);
12842
-
12843
- MVT VT = Op.getSimpleValueType();
12844
-
12845
- SDValue Op1 =
12846
- convertToScalableVector(ContainerVT, Op.getOperand(0), DAG, Subtarget);
12847
- SDValue Op2 =
12848
- convertToScalableVector(ContainerVT, Op.getOperand(1), DAG, Subtarget);
12849
-
12850
- SDLoc DL(Op);
12851
- auto [Mask, VL] = getDefaultVLOps(VT.getVectorNumElements(), ContainerVT, DL,
12852
- DAG, Subtarget);
12853
- MVT MaskVT = getMaskTypeFor(ContainerVT);
12854
-
12855
- SDValue Cmp =
12856
- DAG.getNode(RISCVISD::SETCC_VL, DL, MaskVT,
12857
- {Op1, Op2, Op.getOperand(2), DAG.getUNDEF(MaskVT), Mask, VL});
12858
-
12859
- return convertFromScalableVector(VT, Cmp, DAG, Subtarget);
12860
- }
12861
-
12862
12823
SDValue RISCVTargetLowering::lowerVectorStrictFSetcc(SDValue Op,
12863
12824
SelectionDAG &DAG) const {
12864
12825
unsigned Opc = Op.getOpcode();
@@ -12985,51 +12946,6 @@ SDValue RISCVTargetLowering::lowerABS(SDValue Op, SelectionDAG &DAG) const {
12985
12946
return Max;
12986
12947
}
12987
12948
12988
- SDValue RISCVTargetLowering::lowerFixedLengthVectorFCOPYSIGNToRVV(
12989
- SDValue Op, SelectionDAG &DAG) const {
12990
- SDLoc DL(Op);
12991
- MVT VT = Op.getSimpleValueType();
12992
- SDValue Mag = Op.getOperand(0);
12993
- SDValue Sign = Op.getOperand(1);
12994
- assert(Mag.getValueType() == Sign.getValueType() &&
12995
- "Can only handle COPYSIGN with matching types.");
12996
-
12997
- MVT ContainerVT = getContainerForFixedLengthVector(VT);
12998
- Mag = convertToScalableVector(ContainerVT, Mag, DAG, Subtarget);
12999
- Sign = convertToScalableVector(ContainerVT, Sign, DAG, Subtarget);
13000
-
13001
- auto [Mask, VL] = getDefaultVLOps(VT, ContainerVT, DL, DAG, Subtarget);
13002
-
13003
- SDValue CopySign = DAG.getNode(RISCVISD::FCOPYSIGN_VL, DL, ContainerVT, Mag,
13004
- Sign, DAG.getUNDEF(ContainerVT), Mask, VL);
13005
-
13006
- return convertFromScalableVector(VT, CopySign, DAG, Subtarget);
13007
- }
13008
-
13009
- SDValue RISCVTargetLowering::lowerFixedLengthVectorSelectToRVV(
13010
- SDValue Op, SelectionDAG &DAG) const {
13011
- MVT VT = Op.getSimpleValueType();
13012
- MVT ContainerVT = getContainerForFixedLengthVector(VT);
13013
-
13014
- MVT I1ContainerVT =
13015
- MVT::getVectorVT(MVT::i1, ContainerVT.getVectorElementCount());
13016
-
13017
- SDValue CC =
13018
- convertToScalableVector(I1ContainerVT, Op.getOperand(0), DAG, Subtarget);
13019
- SDValue Op1 =
13020
- convertToScalableVector(ContainerVT, Op.getOperand(1), DAG, Subtarget);
13021
- SDValue Op2 =
13022
- convertToScalableVector(ContainerVT, Op.getOperand(2), DAG, Subtarget);
13023
-
13024
- SDLoc DL(Op);
13025
- SDValue VL = getDefaultVLOps(VT, ContainerVT, DL, DAG, Subtarget).second;
13026
-
13027
- SDValue Select = DAG.getNode(RISCVISD::VMERGE_VL, DL, ContainerVT, CC, Op1,
13028
- Op2, DAG.getUNDEF(ContainerVT), VL);
13029
-
13030
- return convertFromScalableVector(VT, Select, DAG, Subtarget);
13031
- }
13032
-
13033
12949
SDValue RISCVTargetLowering::lowerToScalableOp(SDValue Op,
13034
12950
SelectionDAG &DAG) const {
13035
12951
const auto &TSInfo =
@@ -13056,7 +12972,9 @@ SDValue RISCVTargetLowering::lowerToScalableOp(SDValue Op,
13056
12972
// "cast" fixed length vector to a scalable vector.
13057
12973
assert(useRVVForFixedLengthVectorVT(V.getSimpleValueType()) &&
13058
12974
"Only fixed length vectors are supported!");
13059
- Ops.push_back(convertToScalableVector(ContainerVT, V, DAG, Subtarget));
12975
+ MVT VContainerVT = ContainerVT.changeVectorElementType(
12976
+ V.getSimpleValueType().getVectorElementType());
12977
+ Ops.push_back(convertToScalableVector(VContainerVT, V, DAG, Subtarget));
13060
12978
}
13061
12979
13062
12980
SDLoc DL(Op);
0 commit comments