@@ -25523,6 +25523,9 @@ static SDValue performVSelectCombine(SDNode *N, SelectionDAG &DAG) {
2552325523 return SwapResult;
2552425524
2552525525 SDValue N0 = N->getOperand(0);
25526+ SDValue IfTrue = N->getOperand(1);
25527+ SDValue IfFalse = N->getOperand(2);
25528+ EVT ResVT = N->getValueType(0);
2552625529 EVT CCVT = N0.getValueType();
2552725530
2552825531 if (isAllActivePredicate(DAG, N0))
@@ -25531,6 +25534,22 @@ static SDValue performVSelectCombine(SDNode *N, SelectionDAG &DAG) {
2553125534 if (isAllInactivePredicate(N0))
2553225535 return N->getOperand(2);
2553325536
25537+ if (isMergePassthruOpcode(IfTrue.getOpcode()) && IfTrue.hasOneUse()) {
25538+ // vselect A, (merge_pasthru_op all_active, B,{Bn,} -), C
25539+ // vselect A, (merge_pasthru_op -, B,{Bn,} undef), C
25540+ // vselect A, (merge_pasthru_op A, B,{Bn,} -), C
25541+ // -> merge_pasthru_op A, B,{Bn,} C
25542+ if (isAllActivePredicate(DAG, IfTrue->getOperand(0)) ||
25543+ IfTrue->getOperand(IfTrue.getNumOperands() - 1).isUndef() ||
25544+ IfTrue->getOperand(0) == N0) {
25545+ SmallVector<SDValue, 4> Ops(IfTrue->op_values());
25546+ Ops[0] = N0;
25547+ Ops[IfTrue.getNumOperands() - 1] = IfFalse;
25548+
25549+ return DAG.getNode(IfTrue.getOpcode(), SDLoc(N), ResVT, Ops);
25550+ }
25551+ }
25552+
2553425553 // Check for sign pattern (VSELECT setgt, iN lhs, -1, 1, -1) and transform
2553525554 // into (OR (ASR lhs, N-1), 1), which requires less instructions for the
2553625555 // supported types.
@@ -25570,14 +25589,11 @@ static SDValue performVSelectCombine(SDNode *N, SelectionDAG &DAG) {
2557025589 CmpVT.getVectorElementType().isFloatingPoint())
2557125590 return SDValue();
2557225591
25573- EVT ResVT = N->getValueType(0);
2557425592 // Only combine when the result type is of the same size as the compared
2557525593 // operands.
2557625594 if (ResVT.getSizeInBits() != CmpVT.getSizeInBits())
2557725595 return SDValue();
2557825596
25579- SDValue IfTrue = N->getOperand(1);
25580- SDValue IfFalse = N->getOperand(2);
2558125597 SetCC = DAG.getSetCC(SDLoc(N), CmpVT.changeVectorElementTypeToInteger(),
2558225598 N0.getOperand(0), N0.getOperand(1),
2558325599 cast<CondCodeSDNode>(N0.getOperand(2))->get());
0 commit comments