@@ -146,7 +146,7 @@ class VectorLegalizer {
146
146
SDValue ExpandFCOPYSIGN (SDNode *Node);
147
147
void ExpandFSUB (SDNode *Node, SmallVectorImpl<SDValue> &Results);
148
148
void ExpandSETCC (SDNode *Node, SmallVectorImpl<SDValue> &Results);
149
- void ExpandBITREVERSE (SDNode *Node, SmallVectorImpl<SDValue> &Results );
149
+ SDValue ExpandBITREVERSE (SDNode *Node);
150
150
void ExpandUADDSUBO (SDNode *Node, SmallVectorImpl<SDValue> &Results);
151
151
void ExpandSADDSUBO (SDNode *Node, SmallVectorImpl<SDValue> &Results);
152
152
void ExpandMULO (SDNode *Node, SmallVectorImpl<SDValue> &Results);
@@ -867,8 +867,11 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
867
867
Results.push_back (Node->getOperand (i));
868
868
return ;
869
869
case ISD::SIGN_EXTEND_INREG:
870
- Results.push_back (ExpandSEXTINREG (Node));
871
- return ;
870
+ if (SDValue Expanded = ExpandSEXTINREG (Node)) {
871
+ Results.push_back (Expanded);
872
+ return ;
873
+ }
874
+ break ;
872
875
case ISD::ANY_EXTEND_VECTOR_INREG:
873
876
Results.push_back (ExpandANY_EXTEND_VECTOR_INREG (Node));
874
877
return ;
@@ -879,17 +882,26 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
879
882
Results.push_back (ExpandZERO_EXTEND_VECTOR_INREG (Node));
880
883
return ;
881
884
case ISD::BSWAP:
882
- Results.push_back (ExpandBSWAP (Node));
883
- return ;
885
+ if (SDValue Expanded = ExpandBSWAP (Node)) {
886
+ Results.push_back (Expanded);
887
+ return ;
888
+ }
889
+ break ;
884
890
case ISD::VP_BSWAP:
885
891
Results.push_back (TLI.expandVPBSWAP (Node, DAG));
886
892
return ;
887
893
case ISD::VSELECT:
888
- Results.push_back (ExpandVSELECT (Node));
889
- return ;
894
+ if (SDValue Expanded = ExpandVSELECT (Node)) {
895
+ Results.push_back (Expanded);
896
+ return ;
897
+ }
898
+ break ;
890
899
case ISD::VP_SELECT:
891
- Results.push_back (ExpandVP_SELECT (Node));
892
- return ;
900
+ if (SDValue Expanded = ExpandVP_SELECT (Node)) {
901
+ Results.push_back (Expanded);
902
+ return ;
903
+ }
904
+ break ;
893
905
case ISD::VP_SREM:
894
906
case ISD::VP_UREM:
895
907
if (SDValue Expanded = ExpandVP_REM (Node)) {
@@ -916,8 +928,11 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
916
928
}
917
929
break ;
918
930
case ISD::SELECT:
919
- Results.push_back (ExpandSELECT (Node));
920
- return ;
931
+ if (SDValue Expanded = ExpandSELECT (Node)) {
932
+ Results.push_back (Expanded);
933
+ return ;
934
+ }
935
+ break ;
921
936
case ISD::SELECT_CC: {
922
937
if (Node->getValueType (0 ).isScalableVector ()) {
923
938
EVT CondVT = TLI.getSetCCResultType (
@@ -986,8 +1001,11 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
986
1001
}
987
1002
break ;
988
1003
case ISD::BITREVERSE:
989
- ExpandBITREVERSE (Node, Results);
990
- return ;
1004
+ if (SDValue Expanded = ExpandBITREVERSE (Node)) {
1005
+ Results.push_back (Expanded);
1006
+ return ;
1007
+ }
1008
+ break ;
991
1009
case ISD::VP_BITREVERSE:
992
1010
if (SDValue Expanded = TLI.expandVPBITREVERSE (Node, DAG)) {
993
1011
Results.push_back (Expanded);
@@ -1160,8 +1178,11 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
1160
1178
ExpandREM (Node, Results);
1161
1179
return ;
1162
1180
case ISD::VP_MERGE:
1163
- Results.push_back (ExpandVP_MERGE (Node));
1164
- return ;
1181
+ if (SDValue Expanded = ExpandVP_MERGE (Node)) {
1182
+ Results.push_back (Expanded);
1183
+ return ;
1184
+ }
1185
+ break ;
1165
1186
case ISD::FREM:
1166
1187
if (tryExpandVecMathCall (Node, RTLIB::REM_F32, RTLIB::REM_F64,
1167
1188
RTLIB::REM_F80, RTLIB::REM_F128,
@@ -1217,7 +1238,7 @@ SDValue VectorLegalizer::ExpandSELECT(SDNode *Node) {
1217
1238
TLI.getOperationAction (VT.isFixedLengthVector () ? ISD::BUILD_VECTOR
1218
1239
: ISD::SPLAT_VECTOR,
1219
1240
VT) == TargetLowering::Expand)
1220
- return DAG. UnrollVectorOp (Node );
1241
+ return SDValue ( );
1221
1242
1222
1243
// Generate a mask operand.
1223
1244
EVT MaskTy = VT.changeVectorElementTypeToInteger ();
@@ -1251,7 +1272,7 @@ SDValue VectorLegalizer::ExpandSEXTINREG(SDNode *Node) {
1251
1272
// Make sure that the SRA and SHL instructions are available.
1252
1273
if (TLI.getOperationAction (ISD::SRA, VT) == TargetLowering::Expand ||
1253
1274
TLI.getOperationAction (ISD::SHL, VT) == TargetLowering::Expand)
1254
- return DAG. UnrollVectorOp (Node );
1275
+ return SDValue ( );
1255
1276
1256
1277
SDLoc DL (Node);
1257
1278
EVT OrigTy = cast<VTSDNode>(Node->getOperand (1 ))->getVT ();
@@ -1396,26 +1417,20 @@ SDValue VectorLegalizer::ExpandBSWAP(SDNode *Node) {
1396
1417
TLI.isOperationLegalOrCustomOrPromote (ISD::OR, VT))
1397
1418
return TLI.expandBSWAP (Node, DAG);
1398
1419
1399
- // Otherwise unroll.
1400
- return DAG. UnrollVectorOp (Node );
1420
+ // Otherwise let the caller unroll.
1421
+ return SDValue ( );
1401
1422
}
1402
1423
1403
- void VectorLegalizer::ExpandBITREVERSE (SDNode *Node,
1404
- SmallVectorImpl<SDValue> &Results) {
1424
+ SDValue VectorLegalizer::ExpandBITREVERSE (SDNode *Node) {
1405
1425
EVT VT = Node->getValueType (0 );
1406
1426
1407
1427
// We can't unroll or use shuffles for scalable vectors.
1408
- if (VT.isScalableVector ()) {
1409
- Results.push_back (TLI.expandBITREVERSE (Node, DAG));
1410
- return ;
1411
- }
1428
+ if (VT.isScalableVector ())
1429
+ return TLI.expandBITREVERSE (Node, DAG);
1412
1430
1413
1431
// If we have the scalar operation, it's probably cheaper to unroll it.
1414
- if (TLI.isOperationLegalOrCustom (ISD::BITREVERSE, VT.getScalarType ())) {
1415
- SDValue Tmp = DAG.UnrollVectorOp (Node);
1416
- Results.push_back (Tmp);
1417
- return ;
1418
- }
1432
+ if (TLI.isOperationLegalOrCustom (ISD::BITREVERSE, VT.getScalarType ()))
1433
+ return SDValue ();
1419
1434
1420
1435
// If the vector element width is a whole number of bytes, test if its legal
1421
1436
// to BSWAP shuffle the bytes and then perform the BITREVERSE on the byte
@@ -1438,8 +1453,7 @@ void VectorLegalizer::ExpandBITREVERSE(SDNode *Node,
1438
1453
BSWAPMask);
1439
1454
Op = DAG.getNode (ISD::BITREVERSE, DL, ByteVT, Op);
1440
1455
Op = DAG.getNode (ISD::BITCAST, DL, VT, Op);
1441
- Results.push_back (Op);
1442
- return ;
1456
+ return Op;
1443
1457
}
1444
1458
}
1445
1459
@@ -1448,14 +1462,11 @@ void VectorLegalizer::ExpandBITREVERSE(SDNode *Node,
1448
1462
if (TLI.isOperationLegalOrCustom (ISD::SHL, VT) &&
1449
1463
TLI.isOperationLegalOrCustom (ISD::SRL, VT) &&
1450
1464
TLI.isOperationLegalOrCustomOrPromote (ISD::AND, VT) &&
1451
- TLI.isOperationLegalOrCustomOrPromote (ISD::OR, VT)) {
1452
- Results.push_back (TLI.expandBITREVERSE (Node, DAG));
1453
- return ;
1454
- }
1465
+ TLI.isOperationLegalOrCustomOrPromote (ISD::OR, VT))
1466
+ return TLI.expandBITREVERSE (Node, DAG);
1455
1467
1456
1468
// Otherwise unroll.
1457
- SDValue Tmp = DAG.UnrollVectorOp (Node);
1458
- Results.push_back (Tmp);
1469
+ return SDValue ();
1459
1470
}
1460
1471
1461
1472
SDValue VectorLegalizer::ExpandVSELECT (SDNode *Node) {
@@ -1476,7 +1487,7 @@ SDValue VectorLegalizer::ExpandVSELECT(SDNode *Node) {
1476
1487
if (TLI.getOperationAction (ISD::AND, VT) == TargetLowering::Expand ||
1477
1488
TLI.getOperationAction (ISD::XOR, VT) == TargetLowering::Expand ||
1478
1489
TLI.getOperationAction (ISD::OR, VT) == TargetLowering::Expand)
1479
- return DAG. UnrollVectorOp (Node );
1490
+ return SDValue ( );
1480
1491
1481
1492
// This operation also isn't safe with AND, OR, XOR when the boolean type is
1482
1493
// 0/1 and the select operands aren't also booleans, as we need an all-ones
@@ -1486,13 +1497,13 @@ SDValue VectorLegalizer::ExpandVSELECT(SDNode *Node) {
1486
1497
if (BoolContents != TargetLowering::ZeroOrNegativeOneBooleanContent &&
1487
1498
!(BoolContents == TargetLowering::ZeroOrOneBooleanContent &&
1488
1499
Op1.getValueType ().getVectorElementType () == MVT::i1))
1489
- return DAG. UnrollVectorOp (Node );
1500
+ return SDValue ( );
1490
1501
1491
1502
// If the mask and the type are different sizes, unroll the vector op. This
1492
1503
// can occur when getSetCCResultType returns something that is different in
1493
1504
// size from the operand types. For example, v4i8 = select v4i32, v4i8, v4i8.
1494
1505
if (VT.getSizeInBits () != Op1.getValueSizeInBits ())
1495
- return DAG. UnrollVectorOp (Node );
1506
+ return SDValue ( );
1496
1507
1497
1508
// Bitcast the operands to be the same type as the mask.
1498
1509
// This is needed when we select between FP types because
@@ -1525,11 +1536,11 @@ SDValue VectorLegalizer::ExpandVP_SELECT(SDNode *Node) {
1525
1536
if (TLI.getOperationAction (ISD::VP_AND, VT) == TargetLowering::Expand ||
1526
1537
TLI.getOperationAction (ISD::VP_XOR, VT) == TargetLowering::Expand ||
1527
1538
TLI.getOperationAction (ISD::VP_OR, VT) == TargetLowering::Expand)
1528
- return DAG. UnrollVectorOp (Node );
1539
+ return SDValue ( );
1529
1540
1530
1541
// This operation also isn't safe when the operands aren't also booleans.
1531
1542
if (Op1.getValueType ().getVectorElementType () != MVT::i1)
1532
- return DAG. UnrollVectorOp (Node );
1543
+ return SDValue ( );
1533
1544
1534
1545
SDValue Ones = DAG.getAllOnesConstant (DL, VT);
1535
1546
SDValue NotMask = DAG.getNode (ISD::VP_XOR, DL, VT, Mask, Ones, Ones, EVL);
@@ -1563,13 +1574,13 @@ SDValue VectorLegalizer::ExpandVP_MERGE(SDNode *Node) {
1563
1574
(!IsFixedLen &&
1564
1575
(!TLI.isOperationLegalOrCustom (ISD::STEP_VECTOR, EVLVecVT) ||
1565
1576
!TLI.isOperationLegalOrCustom (ISD::SPLAT_VECTOR, EVLVecVT))))
1566
- return DAG. UnrollVectorOp (Node );
1577
+ return SDValue ( );
1567
1578
1568
1579
// If using a SETCC would result in a different type than the mask type,
1569
1580
// unroll.
1570
1581
if (TLI.getSetCCResultType (DAG.getDataLayout (), *DAG.getContext (),
1571
1582
EVLVecVT) != MaskVT)
1572
- return DAG. UnrollVectorOp (Node );
1583
+ return SDValue ( );
1573
1584
1574
1585
SDValue StepVec = DAG.getStepVector (DL, EVLVecVT);
1575
1586
SDValue SplatEVL = DAG.getSplat (EVLVecVT, DL, EVL);
0 commit comments