Skip to content

Commit 30eb97c

Browse files
authored
[X86] commuteSelect - update to use SDPatternMatch. NFC. (#146868)
1 parent 23216b4 commit 30eb97c

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47568,31 +47568,26 @@ static SDValue combineLogicBlendIntoConditionalNegate(
4756847568

4756947569
static SDValue commuteSelect(SDNode *N, SelectionDAG &DAG, const SDLoc &DL,
4757047570
const X86Subtarget &Subtarget) {
47571+
using namespace SDPatternMatch;
4757147572
if (!Subtarget.hasAVX512())
4757247573
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();
4758247574

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))))
4758447581
return SDValue();
4758547582

47586-
if (Cond.getOpcode() != ISD::SETCC || !Cond.hasOneUse())
47583+
if (canCombineAsMaskOperation(LHS, Subtarget) ||
47584+
!canCombineAsMaskOperation(RHS, Subtarget))
4758747585
return SDValue();
4758847586

4758947587
// Commute LHS and RHS to create opportunity to select mask instruction.
4759047588
// (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);
4759647591
return DAG.getSelect(DL, LHS.getValueType(), Cond, RHS, LHS);
4759747592
}
4759847593

0 commit comments

Comments
 (0)