@@ -883,8 +883,11 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
883
883
// splat of 0 or undef) once vector selects supported in SVE codegen. See
884
884
// D68877 for more details.
885
885
for (MVT VT : MVT::integer_scalable_vector_valuetypes()) {
886
- if (isTypeLegal(VT))
886
+ if (isTypeLegal(VT)) {
887
887
setOperationAction(ISD::SPLAT_VECTOR, VT, Custom);
888
+ setOperationAction(ISD::SDIV, VT, Custom);
889
+ setOperationAction(ISD::UDIV, VT, Custom);
890
+ }
888
891
}
889
892
setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i8, Custom);
890
893
setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i16, Custom);
@@ -1280,6 +1283,8 @@ const char *AArch64TargetLowering::getTargetNodeName(unsigned Opcode) const {
1280
1283
case AArch64ISD::CSINC: return "AArch64ISD::CSINC";
1281
1284
case AArch64ISD::THREAD_POINTER: return "AArch64ISD::THREAD_POINTER";
1282
1285
case AArch64ISD::TLSDESC_CALLSEQ: return "AArch64ISD::TLSDESC_CALLSEQ";
1286
+ case AArch64ISD::SDIV_PRED: return "AArch64ISD::SDIV_PRED";
1287
+ case AArch64ISD::UDIV_PRED: return "AArch64ISD::UDIV_PRED";
1283
1288
case AArch64ISD::ADC: return "AArch64ISD::ADC";
1284
1289
case AArch64ISD::SBC: return "AArch64ISD::SBC";
1285
1290
case AArch64ISD::ADDS: return "AArch64ISD::ADDS";
@@ -3342,6 +3347,10 @@ SDValue AArch64TargetLowering::LowerOperation(SDValue Op,
3342
3347
return LowerSPLAT_VECTOR(Op, DAG);
3343
3348
case ISD::EXTRACT_SUBVECTOR:
3344
3349
return LowerEXTRACT_SUBVECTOR(Op, DAG);
3350
+ case ISD::SDIV:
3351
+ return LowerDIV(Op, DAG, AArch64ISD::SDIV_PRED);
3352
+ case ISD::UDIV:
3353
+ return LowerDIV(Op, DAG, AArch64ISD::UDIV_PRED);
3345
3354
case ISD::SRA:
3346
3355
case ISD::SRL:
3347
3356
case ISD::SHL:
@@ -7648,6 +7657,23 @@ SDValue AArch64TargetLowering::LowerDUPQLane(SDValue Op,
7648
7657
return DAG.getNode(ISD::BITCAST, DL, VT, TBL);
7649
7658
}
7650
7659
7660
+ SDValue AArch64TargetLowering::LowerDIV(SDValue Op,
7661
+ SelectionDAG &DAG,
7662
+ unsigned NewOp) const {
7663
+ EVT VT = Op.getValueType();
7664
+ SDLoc DL(Op);
7665
+
7666
+ assert(Op.getOperand(0).getValueType().isScalableVector() &&
7667
+ Op.getOperand(1).getValueType().isScalableVector() &&
7668
+ "Only scalable vectors are supported");
7669
+
7670
+ auto PredTy = VT.getVectorVT(*DAG.getContext(), MVT::i1,
7671
+ VT.getVectorNumElements(), true);
7672
+ SDValue Mask = getPTrue(DAG, DL, PredTy, AArch64SVEPredPattern::all);
7673
+
7674
+ return DAG.getNode(NewOp, DL, VT, Mask, Op.getOperand(0), Op.getOperand(1));
7675
+ }
7676
+
7651
7677
static bool resolveBuildVector(BuildVectorSDNode *BVN, APInt &CnstBits,
7652
7678
APInt &UndefBits) {
7653
7679
EVT VT = BVN->getValueType(0);
@@ -11359,6 +11385,12 @@ static SDValue performIntrinsicCombine(SDNode *N,
11359
11385
N->getOperand(1));
11360
11386
case Intrinsic::aarch64_sve_ext:
11361
11387
return LowerSVEIntrinsicEXT(N, DAG);
11388
+ case Intrinsic::aarch64_sve_sdiv:
11389
+ return DAG.getNode(AArch64ISD::SDIV_PRED, SDLoc(N), N->getValueType(0),
11390
+ N->getOperand(1), N->getOperand(2), N->getOperand(3));
11391
+ case Intrinsic::aarch64_sve_udiv:
11392
+ return DAG.getNode(AArch64ISD::UDIV_PRED, SDLoc(N), N->getValueType(0),
11393
+ N->getOperand(1), N->getOperand(2), N->getOperand(3));
11362
11394
case Intrinsic::aarch64_sve_sel:
11363
11395
return DAG.getNode(ISD::VSELECT, SDLoc(N), N->getValueType(0),
11364
11396
N->getOperand(1), N->getOperand(2), N->getOperand(3));
0 commit comments