Skip to content

Commit 3e8e056

Browse files
committed
[X86] Move hasOneUse check on PCMPGT(X,-1) -> PCMPGT(0,X) inversion folds to the end of the match. NFCI.
Check the cheap parts of the pattern first, and make the more expensive hasOneUse() call as late as possible.
1 parent 060319a commit 3e8e056

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46722,14 +46722,14 @@ static SDValue combineSelect(SDNode *N, SelectionDAG &DAG,
4672246722
return DAG.getNode(N->getOpcode(), DL, VT,
4672346723
DAG.getBitcast(CondVT, CondNot), RHS, LHS);
4672446724

46725-
if (Cond.getOpcode() == X86ISD::PCMPGT && Cond.hasOneUse()) {
46726-
// pcmpgt(X, -1) -> pcmpgt(0, X) to help select/blendv just use the
46727-
// signbit.
46728-
if (ISD::isBuildVectorAllOnes(Cond.getOperand(1).getNode())) {
46729-
Cond = DAG.getNode(X86ISD::PCMPGT, DL, CondVT,
46730-
DAG.getConstant(0, DL, CondVT), Cond.getOperand(0));
46731-
return DAG.getNode(N->getOpcode(), DL, VT, Cond, RHS, LHS);
46732-
}
46725+
// pcmpgt(X, -1) -> pcmpgt(0, X) to help select/blendv just use the
46726+
// signbit.
46727+
if (Cond.getOpcode() == X86ISD::PCMPGT &&
46728+
ISD::isBuildVectorAllOnes(Cond.getOperand(1).getNode()) &&
46729+
Cond.hasOneUse()) {
46730+
Cond = DAG.getNode(X86ISD::PCMPGT, DL, CondVT,
46731+
DAG.getConstant(0, DL, CondVT), Cond.getOperand(0));
46732+
return DAG.getNode(N->getOpcode(), DL, VT, Cond, RHS, LHS);
4673346733
}
4673446734
}
4673546735

@@ -49544,12 +49544,12 @@ static SDValue combineAndMaskToShift(SDNode *N, SelectionDAG &DAG,
4954449544
if (N->getValueType(0) == VT &&
4954549545
supportedVectorShiftWithImm(VT.getSimpleVT(), Subtarget, ISD::SRA)) {
4954649546
SDValue X, Y;
49547-
if (Op1.hasOneUse() && Op1.getOpcode() == X86ISD::PCMPGT &&
49548-
isAllOnesOrAllOnesSplat(Op1.getOperand(1))) {
49547+
if (Op1.getOpcode() == X86ISD::PCMPGT &&
49548+
isAllOnesOrAllOnesSplat(Op1.getOperand(1)) && Op1.hasOneUse()) {
4954949549
X = Op1.getOperand(0);
4955049550
Y = Op0;
49551-
} else if (Op0.hasOneUse() && Op0.getOpcode() == X86ISD::PCMPGT &&
49552-
isAllOnesOrAllOnesSplat(Op0.getOperand(1))) {
49551+
} else if (Op0.getOpcode() == X86ISD::PCMPGT &&
49552+
isAllOnesOrAllOnesSplat(Op0.getOperand(1)) && Op0.hasOneUse()) {
4955349553
X = Op0.getOperand(0);
4955449554
Y = Op1;
4955549555
}

0 commit comments

Comments
 (0)