@@ -47568,31 +47568,26 @@ static SDValue combineLogicBlendIntoConditionalNegate(
47568
47568
47569
47569
static SDValue commuteSelect(SDNode *N, SelectionDAG &DAG, const SDLoc &DL,
47570
47570
const X86Subtarget &Subtarget) {
47571
+ using namespace SDPatternMatch;
47571
47572
if (!Subtarget.hasAVX512())
47572
47573
return SDValue();
47573
- if (N->getOpcode() != ISD::VSELECT)
47574
- return SDValue();
47575
-
47576
- SDValue Cond = N->getOperand(0);
47577
- SDValue LHS = N->getOperand(1);
47578
- SDValue RHS = N->getOperand(2);
47579
-
47580
- if (canCombineAsMaskOperation(LHS, Subtarget))
47581
- return SDValue();
47582
47574
47583
- if (!canCombineAsMaskOperation(RHS, Subtarget))
47575
+ ISD::CondCode CC;
47576
+ SDValue Cond, X, Y, LHS, RHS;
47577
+ if (!sd_match(N, m_VSelect(m_AllOf(m_Value(Cond),
47578
+ m_OneUse(m_SetCC(m_Value(X), m_Value(Y),
47579
+ m_CondCode(CC)))),
47580
+ m_Value(LHS), m_Value(RHS))))
47584
47581
return SDValue();
47585
47582
47586
- if (Cond.getOpcode() != ISD::SETCC || !Cond.hasOneUse())
47583
+ if (canCombineAsMaskOperation(LHS, Subtarget) ||
47584
+ !canCombineAsMaskOperation(RHS, Subtarget))
47587
47585
return SDValue();
47588
47586
47589
47587
// Commute LHS and RHS to create opportunity to select mask instruction.
47590
47588
// (vselect M, L, R) -> (vselect ~M, R, L)
47591
- ISD::CondCode NewCC =
47592
- ISD::getSetCCInverse(cast<CondCodeSDNode>(Cond.getOperand(2))->get(),
47593
- Cond.getOperand(0).getValueType());
47594
- Cond = DAG.getSetCC(SDLoc(Cond), Cond.getValueType(), Cond.getOperand(0),
47595
- Cond.getOperand(1), NewCC);
47589
+ ISD::CondCode NewCC = ISD::getSetCCInverse(CC, X.getValueType());
47590
+ Cond = DAG.getSetCC(SDLoc(Cond), Cond.getValueType(), X, Y, NewCC);
47596
47591
return DAG.getSelect(DL, LHS.getValueType(), Cond, RHS, LHS);
47597
47592
}
47598
47593
0 commit comments