@@ -17930,16 +17930,14 @@ static SDValue tryCombineToBSL(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
17930
17930
EVT VT = N->getValueType(0);
17931
17931
SelectionDAG &DAG = DCI.DAG;
17932
17932
SDLoc DL(N);
17933
+ const auto &Subtarget = DAG.getSubtarget<AArch64Subtarget>();
17933
17934
17934
17935
if (!VT.isVector())
17935
17936
return SDValue();
17936
17937
17937
- // The combining code currently only works for NEON vectors. In particular,
17938
- // it does not work for SVE when dealing with vectors wider than 128 bits.
17939
- // It also doesn't work for streaming mode because it causes generating
17940
- // bsl instructions that are invalid in streaming mode.
17941
- if (TLI.useSVEForFixedLengthVectorVT(
17942
- VT, !DAG.getSubtarget<AArch64Subtarget>().isNeonAvailable()))
17938
+ // The combining code works for NEON, SVE2 and SME.
17939
+ if (TLI.useSVEForFixedLengthVectorVT(VT, !Subtarget.isNeonAvailable()) ||
17940
+ (VT.isScalableVector() && !Subtarget.hasSVE2()))
17943
17941
return SDValue();
17944
17942
17945
17943
SDValue N0 = N->getOperand(0);
@@ -17994,6 +17992,14 @@ static SDValue tryCombineToBSL(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
17994
17992
uint64_t BitMask = Bits == 64 ? -1ULL : ((1ULL << Bits) - 1);
17995
17993
for (int i = 1; i >= 0; --i)
17996
17994
for (int j = 1; j >= 0; --j) {
17995
+ APInt Val1, Val2;
17996
+
17997
+ if (ISD::isConstantSplatVector(N0->getOperand(i).getNode(), Val1) &&
17998
+ ISD::isConstantSplatVector(N1->getOperand(j).getNode(), Val2) &&
17999
+ (BitMask & ~Val1.getZExtValue()) == Val2.getZExtValue()) {
18000
+ return DAG.getNode(AArch64ISD::BSP, DL, VT, N0->getOperand(i),
18001
+ N0->getOperand(1 - i), N1->getOperand(1 - j));
18002
+ }
17997
18003
BuildVectorSDNode *BVN0 = dyn_cast<BuildVectorSDNode>(N0->getOperand(i));
17998
18004
BuildVectorSDNode *BVN1 = dyn_cast<BuildVectorSDNode>(N1->getOperand(j));
17999
18005
if (!BVN0 || !BVN1)
@@ -18009,9 +18015,8 @@ static SDValue tryCombineToBSL(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
18009
18015
break;
18010
18016
}
18011
18017
}
18012
-
18013
18018
if (FoundMatch)
18014
- return DAG.getNode(AArch64ISD::BSP, DL, VT, SDValue(BVN0, 0 ),
18019
+ return DAG.getNode(AArch64ISD::BSP, DL, VT, N0->getOperand(i ),
18015
18020
N0->getOperand(1 - i), N1->getOperand(1 - j));
18016
18021
}
18017
18022
0 commit comments