@@ -25523,6 +25523,9 @@ static SDValue performVSelectCombine(SDNode *N, SelectionDAG &DAG) {
25523
25523
return SwapResult;
25524
25524
25525
25525
SDValue N0 = N->getOperand(0);
25526
+ SDValue IfTrue = N->getOperand(1);
25527
+ SDValue IfFalse = N->getOperand(2);
25528
+ EVT ResVT = N->getValueType(0);
25526
25529
EVT CCVT = N0.getValueType();
25527
25530
25528
25531
if (isAllActivePredicate(DAG, N0))
@@ -25531,6 +25534,22 @@ static SDValue performVSelectCombine(SDNode *N, SelectionDAG &DAG) {
25531
25534
if (isAllInactivePredicate(N0))
25532
25535
return N->getOperand(2);
25533
25536
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
+
25534
25553
// Check for sign pattern (VSELECT setgt, iN lhs, -1, 1, -1) and transform
25535
25554
// into (OR (ASR lhs, N-1), 1), which requires less instructions for the
25536
25555
// supported types.
@@ -25570,14 +25589,11 @@ static SDValue performVSelectCombine(SDNode *N, SelectionDAG &DAG) {
25570
25589
CmpVT.getVectorElementType().isFloatingPoint())
25571
25590
return SDValue();
25572
25591
25573
- EVT ResVT = N->getValueType(0);
25574
25592
// Only combine when the result type is of the same size as the compared
25575
25593
// operands.
25576
25594
if (ResVT.getSizeInBits() != CmpVT.getSizeInBits())
25577
25595
return SDValue();
25578
25596
25579
- SDValue IfTrue = N->getOperand(1);
25580
- SDValue IfFalse = N->getOperand(2);
25581
25597
SetCC = DAG.getSetCC(SDLoc(N), CmpVT.changeVectorElementTypeToInteger(),
25582
25598
N0.getOperand(0), N0.getOperand(1),
25583
25599
cast<CondCodeSDNode>(N0.getOperand(2))->get());
0 commit comments