[llvm] 3e8e056 - [X86] Move hasOneUse check on PCMPGT(X,-1) -> PCMPGT(0,X) inversion folds to the end of the match. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 2 10:28:23 PDT 2023
Author: Simon Pilgrim
Date: 2023-04-02T18:28:14+01:00
New Revision: 3e8e056ece62f099b2ef4c53378ecdaca9da1108
URL: https://github.com/llvm/llvm-project/commit/3e8e056ece62f099b2ef4c53378ecdaca9da1108
DIFF: https://github.com/llvm/llvm-project/commit/3e8e056ece62f099b2ef4c53378ecdaca9da1108.diff
LOG: [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.
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index d3400ad537e4..2b8815a607b1 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -46722,14 +46722,14 @@ static SDValue combineSelect(SDNode *N, SelectionDAG &DAG,
return DAG.getNode(N->getOpcode(), DL, VT,
DAG.getBitcast(CondVT, CondNot), RHS, LHS);
- if (Cond.getOpcode() == X86ISD::PCMPGT && Cond.hasOneUse()) {
- // pcmpgt(X, -1) -> pcmpgt(0, X) to help select/blendv just use the
- // signbit.
- if (ISD::isBuildVectorAllOnes(Cond.getOperand(1).getNode())) {
- Cond = DAG.getNode(X86ISD::PCMPGT, DL, CondVT,
- DAG.getConstant(0, DL, CondVT), Cond.getOperand(0));
- return DAG.getNode(N->getOpcode(), DL, VT, Cond, RHS, LHS);
- }
+ // pcmpgt(X, -1) -> pcmpgt(0, X) to help select/blendv just use the
+ // signbit.
+ if (Cond.getOpcode() == X86ISD::PCMPGT &&
+ ISD::isBuildVectorAllOnes(Cond.getOperand(1).getNode()) &&
+ Cond.hasOneUse()) {
+ Cond = DAG.getNode(X86ISD::PCMPGT, DL, CondVT,
+ DAG.getConstant(0, DL, CondVT), Cond.getOperand(0));
+ return DAG.getNode(N->getOpcode(), DL, VT, Cond, RHS, LHS);
}
}
@@ -49544,12 +49544,12 @@ static SDValue combineAndMaskToShift(SDNode *N, SelectionDAG &DAG,
if (N->getValueType(0) == VT &&
supportedVectorShiftWithImm(VT.getSimpleVT(), Subtarget, ISD::SRA)) {
SDValue X, Y;
- if (Op1.hasOneUse() && Op1.getOpcode() == X86ISD::PCMPGT &&
- isAllOnesOrAllOnesSplat(Op1.getOperand(1))) {
+ if (Op1.getOpcode() == X86ISD::PCMPGT &&
+ isAllOnesOrAllOnesSplat(Op1.getOperand(1)) && Op1.hasOneUse()) {
X = Op1.getOperand(0);
Y = Op0;
- } else if (Op0.hasOneUse() && Op0.getOpcode() == X86ISD::PCMPGT &&
- isAllOnesOrAllOnesSplat(Op0.getOperand(1))) {
+ } else if (Op0.getOpcode() == X86ISD::PCMPGT &&
+ isAllOnesOrAllOnesSplat(Op0.getOperand(1)) && Op0.hasOneUse()) {
X = Op0.getOperand(0);
Y = Op1;
}
More information about the llvm-commits
mailing list