Skip to content

Commit 153c6db

Browse files
authored
[X86] Merge detectZextAbsDiff into combineBasicSADPattern. NFC. (#147368)
detectZextAbsDiff had already been simplified a great deal when it was converted to SDPatternMatch, and a future patch should allow us to match to ISD::ABDU directly making it entirely redundant.
1 parent 6b95aa6 commit 153c6db

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46003,20 +46003,6 @@ static bool detectExtMul(SelectionDAG &DAG, const SDValue &Mul, SDValue &Op0,
4600346003
return false;
4600446004
}
4600546005

46006-
// Given a ABS node, detect the following pattern:
46007-
// (ABS (SUB (ZERO_EXTEND a), (ZERO_EXTEND b))).
46008-
// This is useful as it is the input into a SAD pattern.
46009-
static bool detectZextAbsDiff(SDValue Abs, SDValue &Op0, SDValue &Op1) {
46010-
using namespace SDPatternMatch;
46011-
46012-
// Check if the operands of the sub are zero-extended from vectors of i8.
46013-
return sd_match(
46014-
Abs,
46015-
m_Abs(m_Sub(
46016-
m_AllOf(m_Value(Op0), m_ZExt(m_SpecificVectorElementVT(MVT::i8))),
46017-
m_AllOf(m_Value(Op1), m_ZExt(m_SpecificVectorElementVT(MVT::i8))))));
46018-
}
46019-
4602046006
static SDValue createVPDPBUSD(SelectionDAG &DAG, SDValue LHS, SDValue RHS,
4602146007
unsigned &LogBias, const SDLoc &DL,
4602246008
const X86Subtarget &Subtarget) {
@@ -46379,6 +46365,8 @@ static SDValue combineVPDPBUSDPattern(SDNode *Extract, SelectionDAG &DAG,
4637946365

4638046366
static SDValue combineBasicSADPattern(SDNode *Extract, SelectionDAG &DAG,
4638146367
const X86Subtarget &Subtarget) {
46368+
using namespace SDPatternMatch;
46369+
4638246370
// PSADBW is only supported on SSE2 and up.
4638346371
if (!Subtarget.hasSSE2())
4638446372
return SDValue();
@@ -46399,8 +46387,7 @@ static SDValue combineBasicSADPattern(SDNode *Extract, SelectionDAG &DAG,
4639946387
if (!Root)
4640046388
return SDValue();
4640146389

46402-
// The operand is expected to be zero extended from i8
46403-
// (verified in detectZextAbsDiff).
46390+
// The operand is expected to be zero extended from i8.
4640446391
// In order to convert to i64 and above, additional any/zero/sign
4640546392
// extend is expected.
4640646393
// The zero extend from 32 bit has no mathematical effect on the result.
@@ -46412,9 +46399,15 @@ static SDValue combineBasicSADPattern(SDNode *Extract, SelectionDAG &DAG,
4641246399
Root.getOpcode() == ISD::ANY_EXTEND)
4641346400
Root = Root.getOperand(0);
4641446401

46415-
// Check whether we have an abs-diff pattern feeding into the select.
46402+
// Check whether we have an abdu pattern.
46403+
// TODO: Add handling for ISD::ABDU.
4641646404
SDValue Zext0, Zext1;
46417-
if (!detectZextAbsDiff(Root, Zext0, Zext1))
46405+
if (!sd_match(
46406+
Root,
46407+
m_Abs(m_Sub(m_AllOf(m_Value(Zext0),
46408+
m_ZExt(m_SpecificVectorElementVT(MVT::i8))),
46409+
m_AllOf(m_Value(Zext1),
46410+
m_ZExt(m_SpecificVectorElementVT(MVT::i8)))))))
4641846411
return SDValue();
4641946412

4642046413
// Create the SAD instruction.

0 commit comments

Comments
 (0)