@@ -1192,6 +1192,10 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
1192
1192
setOperationAction(ISD::INSERT_SUBVECTOR, VT, Custom);
1193
1193
}
1194
1194
1195
+ // Legalize unpacked bitcasts to REINTERPRET_CAST.
1196
+ for (auto VT : {MVT::nxv2i32, MVT::nxv2f32})
1197
+ setOperationAction(ISD::BITCAST, VT, Custom);
1198
+
1195
1199
for (auto VT : {MVT::nxv16i1, MVT::nxv8i1, MVT::nxv4i1, MVT::nxv2i1}) {
1196
1200
setOperationAction(ISD::CONCAT_VECTORS, VT, Custom);
1197
1201
setOperationAction(ISD::SELECT, VT, Custom);
@@ -3508,17 +3512,30 @@ SDValue AArch64TargetLowering::LowerFSINCOS(SDValue Op,
3508
3512
return CallResult.first;
3509
3513
}
3510
3514
3515
+ static MVT getSVEContainerType(EVT ContentTy);
3516
+
3511
3517
SDValue AArch64TargetLowering::LowerBITCAST(SDValue Op,
3512
3518
SelectionDAG &DAG) const {
3513
3519
EVT OpVT = Op.getValueType();
3520
+ EVT ArgVT = Op.getOperand(0).getValueType();
3514
3521
3515
3522
if (useSVEForFixedLengthVectorVT(OpVT))
3516
3523
return LowerFixedLengthBitcastToSVE(Op, DAG);
3517
3524
3525
+ if (OpVT == MVT::nxv2f32) {
3526
+ if (ArgVT.isInteger()) {
3527
+ SDValue ExtResult =
3528
+ DAG.getNode(ISD::ANY_EXTEND, SDLoc(Op), getSVEContainerType(ArgVT),
3529
+ Op.getOperand(0));
3530
+ return getSVESafeBitCast(MVT::nxv2f32, ExtResult, DAG);
3531
+ }
3532
+ return getSVESafeBitCast(MVT::nxv2f32, Op.getOperand(0), DAG);
3533
+ }
3534
+
3518
3535
if (OpVT != MVT::f16 && OpVT != MVT::bf16)
3519
3536
return SDValue();
3520
3537
3521
- assert(Op.getOperand(0).getValueType() == MVT::i16);
3538
+ assert(ArgVT == MVT::i16);
3522
3539
SDLoc DL(Op);
3523
3540
3524
3541
Op = DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i32, Op.getOperand(0));
@@ -16866,11 +16883,18 @@ bool AArch64TargetLowering::getPostIndexedAddressParts(
16866
16883
return true;
16867
16884
}
16868
16885
16869
- static void ReplaceBITCASTResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
16870
- SelectionDAG &DAG) {
16886
+ void AArch64TargetLowering:: ReplaceBITCASTResults(
16887
+ SDNode *N, SmallVectorImpl<SDValue> &Results, SelectionDAG &DAG) const {
16871
16888
SDLoc DL(N);
16872
16889
SDValue Op = N->getOperand(0);
16873
16890
16891
+ if (N->getValueType(0) == MVT::nxv2i32 &&
16892
+ Op.getValueType().isFloatingPoint()) {
16893
+ SDValue CastResult = getSVESafeBitCast(MVT::nxv2i64, Op, DAG);
16894
+ Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, MVT::nxv2i32, CastResult));
16895
+ return;
16896
+ }
16897
+
16874
16898
if (N->getValueType(0) != MVT::i16 ||
16875
16899
(Op.getValueType() != MVT::f16 && Op.getValueType() != MVT::bf16))
16876
16900
return;
@@ -18428,8 +18452,6 @@ SDValue AArch64TargetLowering::getSVESafeBitCast(EVT VT, SDValue Op,
18428
18452
18429
18453
EVT PackedVT = getPackedSVEVectorVT(VT.getVectorElementType());
18430
18454
EVT PackedInVT = getPackedSVEVectorVT(InVT.getVectorElementType());
18431
- assert((VT == PackedVT || InVT == PackedInVT) &&
18432
- "Cannot cast between unpacked scalable vector types!");
18433
18455
18434
18456
// Pack input if required.
18435
18457
if (InVT != PackedInVT)
0 commit comments