@@ -582,7 +582,6 @@ namespace {
582
582
SDValue reassociateReduction(unsigned RedOpc, unsigned Opc, const SDLoc &DL,
583
583
EVT VT, SDValue N0, SDValue N1,
584
584
SDNodeFlags Flags = SDNodeFlags());
585
- SDValue foldReductionWithUndefLane(SDNode *N);
586
585
587
586
SDValue visitShiftByConstant(SDNode *N);
588
587
@@ -1350,75 +1349,6 @@ SDValue DAGCombiner::reassociateReduction(unsigned RedOpc, unsigned Opc,
1350
1349
return SDValue();
1351
1350
}
1352
1351
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
-
1422
1352
SDValue DAGCombiner::CombineTo(SDNode *N, const SDValue *To, unsigned NumTo,
1423
1353
bool AddTo) {
1424
1354
assert(N->getNumValues() == NumTo && "Broken CombineTo call!");
@@ -3128,9 +3058,6 @@ SDValue DAGCombiner::visitADD(SDNode *N) {
3128
3058
return DAG.getNode(ISD::ADD, DL, VT, N0.getOperand(0), SV);
3129
3059
}
3130
3060
3131
- if (SDValue R = foldReductionWithUndefLane(N))
3132
- return R;
3133
-
3134
3061
return SDValue();
3135
3062
}
3136
3063
@@ -6074,9 +6001,6 @@ SDValue DAGCombiner::visitIMINMAX(SDNode *N) {
6074
6001
SDLoc(N), VT, N0, N1))
6075
6002
return SD;
6076
6003
6077
- if (SDValue SD = foldReductionWithUndefLane(N))
6078
- return SD;
6079
-
6080
6004
// Simplify the operands using demanded-bits information.
6081
6005
if (SimplifyDemandedBits(SDValue(N, 0)))
6082
6006
return SDValue(N, 0);
@@ -7377,9 +7301,6 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
7377
7301
}
7378
7302
}
7379
7303
}
7380
-
7381
- if (SDValue R = foldReductionWithUndefLane(N))
7382
- return R;
7383
7304
}
7384
7305
7385
7306
// fold (and x, -1) -> x
@@ -8339,9 +8260,6 @@ SDValue DAGCombiner::visitOR(SDNode *N) {
8339
8260
}
8340
8261
}
8341
8262
}
8342
-
8343
- if (SDValue R = foldReductionWithUndefLane(N))
8344
- return R;
8345
8263
}
8346
8264
8347
8265
// fold (or x, 0) -> x
@@ -10023,9 +9941,6 @@ SDValue DAGCombiner::visitXOR(SDNode *N) {
10023
9941
if (SDValue Combined = combineCarryDiamond(DAG, TLI, N0, N1, N))
10024
9942
return Combined;
10025
9943
10026
- if (SDValue R = foldReductionWithUndefLane(N))
10027
- return R;
10028
-
10029
9944
return SDValue();
10030
9945
}
10031
9946
@@ -17642,10 +17557,6 @@ SDValue DAGCombiner::visitFADD(SDNode *N) {
17642
17557
AddToWorklist(Fused.getNode());
17643
17558
return Fused;
17644
17559
}
17645
-
17646
- if (SDValue R = foldReductionWithUndefLane(N))
17647
- return R;
17648
-
17649
17560
return SDValue();
17650
17561
}
17651
17562
@@ -18014,9 +17925,6 @@ SDValue DAGCombiner::visitFMUL(SDNode *N) {
18014
17925
if (SDValue R = combineFMulOrFDivWithIntPow2(N))
18015
17926
return R;
18016
17927
18017
- if (SDValue R = foldReductionWithUndefLane(N))
18018
- return R;
18019
-
18020
17928
return SDValue();
18021
17929
}
18022
17930
@@ -19122,9 +19030,6 @@ SDValue DAGCombiner::visitFMinMax(SDNode *N) {
19122
19030
Opc, SDLoc(N), VT, N0, N1, Flags))
19123
19031
return SD;
19124
19032
19125
- if (SDValue SD = foldReductionWithUndefLane(N))
19126
- return SD;
19127
-
19128
19033
return SDValue();
19129
19034
}
19130
19035
0 commit comments