@@ -853,7 +853,9 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
853
853
854
854
// Integer VTs are lowered as a series of "RISCVISD::TRUNCATE_VECTOR_VL"
855
855
// nodes which truncate by one power of two at a time.
856
- setOperationAction(ISD::TRUNCATE, VT, Custom);
856
+ setOperationAction({ISD::TRUNCATE, ISD::TRUNCATE_SSAT_S,
857
+ ISD::TRUNCATE_SSAT_U, ISD::TRUNCATE_USAT_U},
858
+ VT, Custom);
857
859
858
860
// Custom-lower insert/extract operations to simplify patterns.
859
861
setOperationAction({ISD::INSERT_VECTOR_ELT, ISD::EXTRACT_VECTOR_ELT}, VT,
@@ -1168,7 +1170,9 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
1168
1170
1169
1171
setOperationAction(ISD::SELECT, VT, Custom);
1170
1172
1171
- setOperationAction(ISD::TRUNCATE, VT, Custom);
1173
+ setOperationAction({ISD::TRUNCATE, ISD::TRUNCATE_SSAT_S,
1174
+ ISD::TRUNCATE_SSAT_U, ISD::TRUNCATE_USAT_U},
1175
+ VT, Custom);
1172
1176
1173
1177
setOperationAction(ISD::BITCAST, VT, Custom);
1174
1178
@@ -6395,6 +6399,9 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
6395
6399
return DAG.getNode(RISCVISD::BREV8, DL, VT, BSwap);
6396
6400
}
6397
6401
case ISD::TRUNCATE:
6402
+ case ISD::TRUNCATE_SSAT_S:
6403
+ case ISD::TRUNCATE_SSAT_U:
6404
+ case ISD::TRUNCATE_USAT_U:
6398
6405
// Only custom-lower vector truncates
6399
6406
if (!Op.getSimpleValueType().isVector())
6400
6407
return Op;
@@ -8234,7 +8241,8 @@ SDValue RISCVTargetLowering::lowerVectorMaskTruncLike(SDValue Op,
8234
8241
8235
8242
SDValue RISCVTargetLowering::lowerVectorTruncLike(SDValue Op,
8236
8243
SelectionDAG &DAG) const {
8237
- bool IsVPTrunc = Op.getOpcode() == ISD::VP_TRUNCATE;
8244
+ unsigned Opc = Op.getOpcode();
8245
+ bool IsVPTrunc = Opc == ISD::VP_TRUNCATE;
8238
8246
SDLoc DL(Op);
8239
8247
8240
8248
MVT VT = Op.getSimpleValueType();
@@ -8279,11 +8287,18 @@ SDValue RISCVTargetLowering::lowerVectorTruncLike(SDValue Op,
8279
8287
getDefaultVLOps(SrcVT, ContainerVT, DL, DAG, Subtarget);
8280
8288
}
8281
8289
8290
+ unsigned NewOpc;
8291
+ if (Opc == ISD::TRUNCATE_SSAT_S)
8292
+ NewOpc = RISCVISD::TRUNCATE_VECTOR_VL_SSAT;
8293
+ else if (Opc == ISD::TRUNCATE_SSAT_U || Opc == ISD::TRUNCATE_USAT_U)
8294
+ NewOpc = RISCVISD::TRUNCATE_VECTOR_VL_USAT;
8295
+ else
8296
+ NewOpc = RISCVISD::TRUNCATE_VECTOR_VL;
8297
+
8282
8298
do {
8283
8299
SrcEltVT = MVT::getIntegerVT(SrcEltVT.getSizeInBits() / 2);
8284
8300
MVT ResultVT = ContainerVT.changeVectorElementType(SrcEltVT);
8285
- Result = DAG.getNode(RISCVISD::TRUNCATE_VECTOR_VL, DL, ResultVT, Result,
8286
- Mask, VL);
8301
+ Result = DAG.getNode(NewOpc, DL, ResultVT, Result, Mask, VL);
8287
8302
} while (SrcEltVT != DstEltVT);
8288
8303
8289
8304
if (SrcVT.isFixedLengthVector())
0 commit comments