@@ -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-
4602046006static 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
4638046366static 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