@@ -582,7 +582,6 @@ namespace {
582582 SDValue reassociateReduction(unsigned RedOpc, unsigned Opc, const SDLoc &DL,
583583 EVT VT, SDValue N0, SDValue N1,
584584 SDNodeFlags Flags = SDNodeFlags());
585- SDValue foldReductionWithUndefLane(SDNode *N);
586585
587586 SDValue visitShiftByConstant(SDNode *N);
588587
@@ -1350,75 +1349,6 @@ SDValue DAGCombiner::reassociateReduction(unsigned RedOpc, unsigned Opc,
13501349 return SDValue();
13511350}
13521351
1353- // Convert:
1354- // (op.x2 (vector_shuffle<i,u> A), B) -> <(op A:i, B:0) undef>
1355- // ...or...
1356- // (op.x2 (vector_shuffle<u,i> A), B) -> <undef (op A:i, B:1)>
1357- // ...where i is a valid index and u is poison.
1358- SDValue DAGCombiner::foldReductionWithUndefLane(SDNode *N) {
1359- const EVT VectorVT = N->getValueType(0);
1360-
1361- // Only support 2-packed vectors for now.
1362- if (!VectorVT.isVector() || VectorVT.isScalableVector()
1363- || VectorVT.getVectorNumElements() != 2)
1364- return SDValue();
1365-
1366- // If the operation is already unsupported, we don't need to do this
1367- // operation.
1368- if (!TLI.isOperationLegal(N->getOpcode(), VectorVT))
1369- return SDValue();
1370-
1371- // If vector shuffle is supported on the target, this optimization may
1372- // increase register pressure.
1373- if (TLI.isOperationLegalOrCustomOrPromote(ISD::VECTOR_SHUFFLE, VectorVT))
1374- return SDValue();
1375-
1376- SDLoc DL(N);
1377-
1378- SDValue ShufOp = N->getOperand(0);
1379- SDValue VectOp = N->getOperand(1);
1380- bool Swapped = false;
1381-
1382- // canonicalize shuffle op
1383- if (VectOp.getOpcode() == ISD::VECTOR_SHUFFLE) {
1384- std::swap(ShufOp, VectOp);
1385- Swapped = true;
1386- }
1387-
1388- if (ShufOp.getOpcode() != ISD::VECTOR_SHUFFLE)
1389- return SDValue();
1390-
1391- auto *ShuffleOp = cast<ShuffleVectorSDNode>(ShufOp);
1392- int LiveLane; // exclusively live lane
1393- for (LiveLane = 0; LiveLane < 2; ++LiveLane) {
1394- // check if the current lane is live and the other lane is dead
1395- if (ShuffleOp->getMaskElt(LiveLane) != PoisonMaskElem &&
1396- ShuffleOp->getMaskElt(!LiveLane) == PoisonMaskElem)
1397- break;
1398- }
1399- if (LiveLane == 2)
1400- return SDValue();
1401-
1402- const int ElementIdx = ShuffleOp->getMaskElt(LiveLane);
1403- const EVT ScalarVT = VectorVT.getScalarType();
1404- SDValue Lanes[2] = {};
1405- for (auto [LaneID, LaneVal] : enumerate(Lanes)) {
1406- if (LaneID == (unsigned)LiveLane) {
1407- SDValue Operands[2] = {
1408- DAG.getExtractVectorElt(DL, ScalarVT, ShufOp.getOperand(0),
1409- ElementIdx),
1410- DAG.getExtractVectorElt(DL, ScalarVT, VectOp, LiveLane)};
1411- // preserve the order of operands
1412- if (Swapped)
1413- std::swap(Operands[0], Operands[1]);
1414- LaneVal = DAG.getNode(N->getOpcode(), DL, ScalarVT, Operands);
1415- } else {
1416- LaneVal = DAG.getUNDEF(ScalarVT);
1417- }
1418- }
1419- return DAG.getBuildVector(VectorVT, DL, Lanes);
1420- }
1421-
14221352SDValue DAGCombiner::CombineTo(SDNode *N, const SDValue *To, unsigned NumTo,
14231353 bool AddTo) {
14241354 assert(N->getNumValues() == NumTo && "Broken CombineTo call!");
@@ -3128,9 +3058,6 @@ SDValue DAGCombiner::visitADD(SDNode *N) {
31283058 return DAG.getNode(ISD::ADD, DL, VT, N0.getOperand(0), SV);
31293059 }
31303060
3131- if (SDValue R = foldReductionWithUndefLane(N))
3132- return R;
3133-
31343061 return SDValue();
31353062}
31363063
@@ -6074,9 +6001,6 @@ SDValue DAGCombiner::visitIMINMAX(SDNode *N) {
60746001 SDLoc(N), VT, N0, N1))
60756002 return SD;
60766003
6077- if (SDValue SD = foldReductionWithUndefLane(N))
6078- return SD;
6079-
60806004 // Simplify the operands using demanded-bits information.
60816005 if (SimplifyDemandedBits(SDValue(N, 0)))
60826006 return SDValue(N, 0);
@@ -7377,9 +7301,6 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
73777301 }
73787302 }
73797303 }
7380-
7381- if (SDValue R = foldReductionWithUndefLane(N))
7382- return R;
73837304 }
73847305
73857306 // fold (and x, -1) -> x
@@ -8339,9 +8260,6 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
83398260 }
83408261 }
83418262 }
8342-
8343- if (SDValue R = foldReductionWithUndefLane(N))
8344- return R;
83458263 }
83468264
83478265 // fold (or x, 0) -> x
@@ -10023,9 +9941,6 @@ SDValue DAGCombiner::visitXOR(SDNode *N) {
100239941 if (SDValue Combined = combineCarryDiamond(DAG, TLI, N0, N1, N))
100249942 return Combined;
100259943
10026- if (SDValue R = foldReductionWithUndefLane(N))
10027- return R;
10028-
100299944 return SDValue();
100309945}
100319946
@@ -17642,10 +17557,6 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
1764217557 AddToWorklist(Fused.getNode());
1764317558 return Fused;
1764417559 }
17645-
17646- if (SDValue R = foldReductionWithUndefLane(N))
17647- return R;
17648-
1764917560 return SDValue();
1765017561}
1765117562
@@ -18014,9 +17925,6 @@ SDValue DAGCombiner::visitFMUL(SDNode *N) {
1801417925 if (SDValue R = combineFMulOrFDivWithIntPow2(N))
1801517926 return R;
1801617927
18017- if (SDValue R = foldReductionWithUndefLane(N))
18018- return R;
18019-
1802017928 return SDValue();
1802117929}
1802217930
@@ -19122,9 +19030,6 @@ SDValue DAGCombiner::visitFMinMax(SDNode *N) {
1912219030 Opc, SDLoc(N), VT, N0, N1, Flags))
1912319031 return SD;
1912419032
19125- if (SDValue SD = foldReductionWithUndefLane(N))
19126- return SD;
19127-
1912819033 return SDValue();
1912919034}
1913019035
0 commit comments