@@ -31807,65 +31807,6 @@ static SDValue combineBitcast(SDNode *N, SelectionDAG &DAG,
31807
31807
return SDValue();
31808
31808
}
31809
31809
31810
- // Match a binop + shuffle pyramid that represents a horizontal reduction over
31811
- // the elements of a vector.
31812
- // Returns the vector that is being reduced on, or SDValue() if a reduction
31813
- // was not matched.
31814
- static SDValue matchBinOpReduction(SDNode *Extract, unsigned &BinOp,
31815
- ArrayRef<ISD::NodeType> CandidateBinOps) {
31816
- // The pattern must end in an extract from index 0.
31817
- if ((Extract->getOpcode() != ISD::EXTRACT_VECTOR_ELT) ||
31818
- !isNullConstant(Extract->getOperand(1)))
31819
- return SDValue();
31820
-
31821
- SDValue Op = Extract->getOperand(0);
31822
- unsigned Stages = Log2_32(Op.getValueType().getVectorNumElements());
31823
-
31824
- // Match against one of the candidate binary ops.
31825
- if (llvm::none_of(CandidateBinOps, [Op](ISD::NodeType BinOp) {
31826
- return Op.getOpcode() == unsigned(BinOp);
31827
- }))
31828
- return SDValue();
31829
-
31830
- // At each stage, we're looking for something that looks like:
31831
- // %s = shufflevector <8 x i32> %op, <8 x i32> undef,
31832
- // <8 x i32> <i32 2, i32 3, i32 undef, i32 undef,
31833
- // i32 undef, i32 undef, i32 undef, i32 undef>
31834
- // %a = binop <8 x i32> %op, %s
31835
- // Where the mask changes according to the stage. E.g. for a 3-stage pyramid,
31836
- // we expect something like:
31837
- // <4,5,6,7,u,u,u,u>
31838
- // <2,3,u,u,u,u,u,u>
31839
- // <1,u,u,u,u,u,u,u>
31840
- unsigned CandidateBinOp = Op.getOpcode();
31841
- for (unsigned i = 0; i < Stages; ++i) {
31842
- if (Op.getOpcode() != CandidateBinOp)
31843
- return SDValue();
31844
-
31845
- ShuffleVectorSDNode *Shuffle =
31846
- dyn_cast<ShuffleVectorSDNode>(Op.getOperand(0).getNode());
31847
- if (Shuffle) {
31848
- Op = Op.getOperand(1);
31849
- } else {
31850
- Shuffle = dyn_cast<ShuffleVectorSDNode>(Op.getOperand(1).getNode());
31851
- Op = Op.getOperand(0);
31852
- }
31853
-
31854
- // The first operand of the shuffle should be the same as the other operand
31855
- // of the binop.
31856
- if (!Shuffle || Shuffle->getOperand(0) != Op)
31857
- return SDValue();
31858
-
31859
- // Verify the shuffle has the expected (at this stage of the pyramid) mask.
31860
- for (int Index = 0, MaskEnd = 1 << i; Index < MaskEnd; ++Index)
31861
- if (Shuffle->getMaskElt(Index) != MaskEnd + Index)
31862
- return SDValue();
31863
- }
31864
-
31865
- BinOp = CandidateBinOp;
31866
- return Op;
31867
- }
31868
-
31869
31810
// Given a select, detect the following pattern:
31870
31811
// 1: %2 = zext <N x i8> %0 to <N x i32>
31871
31812
// 2: %3 = zext <N x i8> %1 to <N x i32>
@@ -31980,8 +31921,8 @@ static SDValue combineHorizontalMinMaxResult(SDNode *Extract, SelectionDAG &DAG,
31980
31921
return SDValue();
31981
31922
31982
31923
// Check for SMAX/SMIN/UMAX/UMIN horizontal reduction patterns.
31983
- unsigned BinOp;
31984
- SDValue Src = matchBinOpReduction(
31924
+ ISD::NodeType BinOp;
31925
+ SDValue Src = DAG. matchBinOpReduction(
31985
31926
Extract, BinOp, {ISD::SMAX, ISD::SMIN, ISD::UMAX, ISD::UMIN});
31986
31927
if (!Src)
31987
31928
return SDValue();
@@ -32060,8 +32001,8 @@ static SDValue combineHorizontalPredicateResult(SDNode *Extract,
32060
32001
return SDValue();
32061
32002
32062
32003
// Check for OR(any_of) and AND(all_of) horizontal reduction patterns.
32063
- unsigned BinOp = 0 ;
32064
- SDValue Match = matchBinOpReduction(Extract, BinOp, {ISD::OR, ISD::AND});
32004
+ ISD::NodeType BinOp;
32005
+ SDValue Match = DAG. matchBinOpReduction(Extract, BinOp, {ISD::OR, ISD::AND});
32065
32006
if (!Match)
32066
32007
return SDValue();
32067
32008
@@ -32143,8 +32084,8 @@ static SDValue combineBasicSADPattern(SDNode *Extract, SelectionDAG &DAG,
32143
32084
return SDValue();
32144
32085
32145
32086
// Match shuffle + add pyramid.
32146
- unsigned BinOp = 0 ;
32147
- SDValue Root = matchBinOpReduction(Extract, BinOp, {ISD::ADD});
32087
+ ISD::NodeType BinOp;
32088
+ SDValue Root = DAG. matchBinOpReduction(Extract, BinOp, {ISD::ADD});
32148
32089
32149
32090
// The operand is expected to be zero extended from i8
32150
32091
// (verified in detectZextAbsDiff).
0 commit comments