@@ -824,6 +824,10 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
824
824
setOperationAction(ISD::SELECT, MVT::v4i32,
825
825
Subtarget.useCRBits() ? Legal : Expand);
826
826
setOperationAction(ISD::STORE , MVT::v4i32, Legal);
827
+ setOperationAction(ISD::STRICT_FP_TO_SINT, MVT::v4i32, Legal);
828
+ setOperationAction(ISD::STRICT_FP_TO_UINT, MVT::v4i32, Legal);
829
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::v4i32, Legal);
830
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::v4i32, Legal);
827
831
setOperationAction(ISD::FP_TO_SINT, MVT::v4i32, Legal);
828
832
setOperationAction(ISD::FP_TO_UINT, MVT::v4i32, Legal);
829
833
setOperationAction(ISD::SINT_TO_FP, MVT::v4i32, Legal);
@@ -1002,6 +1006,10 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
1002
1006
1003
1007
setOperationAction(ISD::VECTOR_SHUFFLE, MVT::v2i64, Legal);
1004
1008
1009
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::v2i64, Legal);
1010
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::v2i64, Legal);
1011
+ setOperationAction(ISD::STRICT_FP_TO_SINT, MVT::v2i64, Legal);
1012
+ setOperationAction(ISD::STRICT_FP_TO_UINT, MVT::v2i64, Legal);
1005
1013
setOperationAction(ISD::SINT_TO_FP, MVT::v2i64, Legal);
1006
1014
setOperationAction(ISD::UINT_TO_FP, MVT::v2i64, Legal);
1007
1015
setOperationAction(ISD::FP_TO_SINT, MVT::v2i64, Legal);
@@ -1010,6 +1018,14 @@ PPCTargetLowering::PPCTargetLowering(const PPCTargetMachine &TM,
1010
1018
// Custom handling for partial vectors of integers converted to
1011
1019
// floating point. We already have optimal handling for v2i32 through
1012
1020
// the DAG combine, so those aren't necessary.
1021
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::v2i8, Custom);
1022
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::v4i8, Custom);
1023
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::v2i16, Custom);
1024
+ setOperationAction(ISD::STRICT_UINT_TO_FP, MVT::v4i16, Custom);
1025
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::v2i8, Custom);
1026
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::v4i8, Custom);
1027
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::v2i16, Custom);
1028
+ setOperationAction(ISD::STRICT_SINT_TO_FP, MVT::v4i16, Custom);
1013
1029
setOperationAction(ISD::UINT_TO_FP, MVT::v2i8, Custom);
1014
1030
setOperationAction(ISD::UINT_TO_FP, MVT::v4i8, Custom);
1015
1031
setOperationAction(ISD::UINT_TO_FP, MVT::v2i16, Custom);
@@ -8346,17 +8362,19 @@ static SDValue widenVec(SelectionDAG &DAG, SDValue Vec, const SDLoc &dl) {
8346
8362
8347
8363
SDValue PPCTargetLowering::LowerINT_TO_FPVector(SDValue Op, SelectionDAG &DAG,
8348
8364
const SDLoc &dl) const {
8349
-
8365
+ bool IsStrict = Op->isStrictFPOpcode();
8350
8366
unsigned Opc = Op.getOpcode();
8351
- assert((Opc == ISD::UINT_TO_FP || Opc == ISD::SINT_TO_FP) &&
8367
+ SDValue Src = Op.getOperand(IsStrict ? 1 : 0);
8368
+ assert((Opc == ISD::UINT_TO_FP || Opc == ISD::SINT_TO_FP ||
8369
+ Opc == ISD::STRICT_UINT_TO_FP || Opc == ISD::STRICT_SINT_TO_FP) &&
8352
8370
"Unexpected conversion type");
8353
8371
assert((Op.getValueType() == MVT::v2f64 || Op.getValueType() == MVT::v4f32) &&
8354
8372
"Supports conversions to v2f64/v4f32 only.");
8355
8373
8356
- bool SignedConv = Opc == ISD::SINT_TO_FP;
8374
+ bool SignedConv = Opc == ISD::SINT_TO_FP || Opc == ISD::STRICT_SINT_TO_FP ;
8357
8375
bool FourEltRes = Op.getValueType() == MVT::v4f32;
8358
8376
8359
- SDValue Wide = widenVec(DAG, Op.getOperand(0) , dl);
8377
+ SDValue Wide = widenVec(DAG, Src , dl);
8360
8378
EVT WideVT = Wide.getValueType();
8361
8379
unsigned WideNumElts = WideVT.getVectorNumElements();
8362
8380
MVT IntermediateVT = FourEltRes ? MVT::v4i32 : MVT::v2i64;
@@ -8381,7 +8399,7 @@ SDValue PPCTargetLowering::LowerINT_TO_FPVector(SDValue Op, SelectionDAG &DAG,
8381
8399
SDValue Extend;
8382
8400
if (SignedConv) {
8383
8401
Arrange = DAG.getBitcast(IntermediateVT, Arrange);
8384
- EVT ExtVT = Op.getOperand(0) .getValueType();
8402
+ EVT ExtVT = Src .getValueType();
8385
8403
if (Subtarget.hasP9Altivec())
8386
8404
ExtVT = EVT::getVectorVT(*DAG.getContext(), WideVT.getVectorElementType(),
8387
8405
IntermediateVT.getVectorNumElements());
@@ -8391,6 +8409,10 @@ SDValue PPCTargetLowering::LowerINT_TO_FPVector(SDValue Op, SelectionDAG &DAG,
8391
8409
} else
8392
8410
Extend = DAG.getNode(ISD::BITCAST, dl, IntermediateVT, Arrange);
8393
8411
8412
+ if (IsStrict)
8413
+ return DAG.getNode(Opc, dl, {Op.getValueType(), MVT::Other},
8414
+ {Op.getOperand(0), Extend});
8415
+
8394
8416
return DAG.getNode(Opc, dl, Op.getValueType(), Extend);
8395
8417
}
8396
8418
@@ -10648,6 +10670,28 @@ SDValue PPCTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
10648
10670
}
10649
10671
}
10650
10672
10673
+ void PPCTargetLowering::LowerOperationWrapper(SDNode *N,
10674
+ SmallVectorImpl<SDValue> &Results,
10675
+ SelectionDAG &DAG) const {
10676
+ SDValue Res = LowerOperation(SDValue(N, 0), DAG);
10677
+
10678
+ if (!Res.getNode())
10679
+ return;
10680
+
10681
+ // Take the return value as-is if original node has only one result.
10682
+ if (N->getNumValues() == 1) {
10683
+ Results.push_back(Res);
10684
+ return;
10685
+ }
10686
+
10687
+ // New node should have the same number of results.
10688
+ assert((N->getNumValues() == Res->getNumValues()) &&
10689
+ "Lowering returned the wrong number of results!");
10690
+
10691
+ for (unsigned i = 0; i < N->getNumValues(); ++i)
10692
+ Results.push_back(Res.getValue(i));
10693
+ }
10694
+
10651
10695
void PPCTargetLowering::ReplaceNodeResults(SDNode *N,
10652
10696
SmallVectorImpl<SDValue>&Results,
10653
10697
SelectionDAG &DAG) const {
0 commit comments