@@ -621,21 +621,21 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
621
621
setOperationAction (ISD::CTLZ, Ty, Legal);
622
622
}
623
623
624
- setI16x2OperationAction (ISD::ABS, MVT::v2i16, Legal, Expand );
625
- setI16x2OperationAction (ISD::SMIN, MVT::v2i16, Legal, Expand );
626
- setI16x2OperationAction (ISD::SMAX, MVT::v2i16, Legal, Expand );
627
- setI16x2OperationAction (ISD::UMIN, MVT::v2i16, Legal, Expand );
628
- setI16x2OperationAction (ISD::UMAX, MVT::v2i16, Legal, Expand );
624
+ setI16x2OperationAction (ISD::ABS, MVT::v2i16, Legal, Custom );
625
+ setI16x2OperationAction (ISD::SMIN, MVT::v2i16, Legal, Custom );
626
+ setI16x2OperationAction (ISD::SMAX, MVT::v2i16, Legal, Custom );
627
+ setI16x2OperationAction (ISD::UMIN, MVT::v2i16, Legal, Custom );
628
+ setI16x2OperationAction (ISD::UMAX, MVT::v2i16, Legal, Custom );
629
629
setI16x2OperationAction (ISD::CTPOP, MVT::v2i16, Legal, Expand);
630
630
setI16x2OperationAction (ISD::CTLZ, MVT::v2i16, Legal, Expand);
631
631
632
- setI16x2OperationAction (ISD::ADD, MVT::v2i16, Legal, Expand );
633
- setI16x2OperationAction (ISD::SUB, MVT::v2i16, Legal, Expand );
634
- setI16x2OperationAction (ISD::AND, MVT::v2i16, Legal, Expand );
635
- setI16x2OperationAction (ISD::MUL, MVT::v2i16, Legal, Expand );
636
- setI16x2OperationAction (ISD::SHL, MVT::v2i16, Legal, Expand );
637
- setI16x2OperationAction (ISD::SREM, MVT::v2i16, Legal, Expand );
638
- setI16x2OperationAction (ISD::UREM, MVT::v2i16, Legal, Expand );
632
+ setI16x2OperationAction (ISD::ADD, MVT::v2i16, Legal, Custom );
633
+ setI16x2OperationAction (ISD::SUB, MVT::v2i16, Legal, Custom );
634
+ setI16x2OperationAction (ISD::AND, MVT::v2i16, Legal, Custom );
635
+ setI16x2OperationAction (ISD::MUL, MVT::v2i16, Legal, Custom );
636
+ setI16x2OperationAction (ISD::SHL, MVT::v2i16, Legal, Custom );
637
+ setI16x2OperationAction (ISD::SREM, MVT::v2i16, Legal, Custom );
638
+ setI16x2OperationAction (ISD::UREM, MVT::v2i16, Legal, Custom );
639
639
640
640
setOperationAction (ISD::ADDC, MVT::i32, Legal);
641
641
setOperationAction (ISD::ADDE, MVT::i32, Legal);
@@ -2418,7 +2418,26 @@ SDValue NVPTXTargetLowering::LowerFROUND64(SDValue Op,
2418
2418
return DAG.getNode (ISD::SELECT, SL, VT, IsLarge, A, RoundedA);
2419
2419
}
2420
2420
2421
-
2421
+ static SDValue LowerVectorArith (SDValue Op, SelectionDAG &DAG) {
2422
+ SDLoc DL (Op);
2423
+ if (Op.getValueType () != MVT::v2i16)
2424
+ return Op;
2425
+ EVT EltVT = Op.getValueType ().getVectorElementType ();
2426
+ SmallVector<SDValue> VecElements;
2427
+ for (int I = 0 , E = Op.getValueType ().getVectorNumElements (); I < E; I++) {
2428
+ SmallVector<SDValue> ScalarArgs;
2429
+ for (int J = 0 , NumOp = Op.getNumOperands (); J < NumOp; J++) {
2430
+ SDValue Ext =
2431
+ DAG.getNode (ISD::EXTRACT_VECTOR_ELT, DL, EltVT, Op->getOperand (J),
2432
+ DAG.getIntPtrConstant (I, DL));
2433
+ ScalarArgs.push_back (Ext);
2434
+ }
2435
+ VecElements.push_back (DAG.getNode (Op.getOpcode (), DL, EltVT, ScalarArgs));
2436
+ }
2437
+ SDValue V =
2438
+ DAG.getNode (ISD::BUILD_VECTOR, DL, Op.getValueType (), VecElements);
2439
+ return V;
2440
+ }
2422
2441
2423
2442
SDValue
2424
2443
NVPTXTargetLowering::LowerOperation (SDValue Op, SelectionDAG &DAG) const {
@@ -2456,6 +2475,19 @@ NVPTXTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
2456
2475
return LowerVAARG (Op, DAG);
2457
2476
case ISD::VASTART:
2458
2477
return LowerVASTART (Op, DAG);
2478
+ case ISD::ABS:
2479
+ case ISD::SMIN:
2480
+ case ISD::SMAX:
2481
+ case ISD::UMIN:
2482
+ case ISD::UMAX:
2483
+ case ISD::ADD:
2484
+ case ISD::SUB:
2485
+ case ISD::AND:
2486
+ case ISD::MUL:
2487
+ case ISD::SHL:
2488
+ case ISD::SREM:
2489
+ case ISD::UREM:
2490
+ return LowerVectorArith (Op, DAG);
2459
2491
default :
2460
2492
llvm_unreachable (" Custom lowering not defined for operation" );
2461
2493
}
0 commit comments