Skip to content

Commit 01be025

Browse files
committed
[X86] combinePMULH - simplify pattern matching with SDPatternMatch. NFC.
1 parent 8e68a51 commit 01be025

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52983,10 +52983,7 @@ static SDValue combineTruncatedArithmetic(SDNode *N, SelectionDAG &DAG,
5298352983
// combiner.
5298452984
static SDValue combinePMULH(SDValue Src, EVT VT, const SDLoc &DL,
5298552985
SelectionDAG &DAG, const X86Subtarget &Subtarget) {
52986-
// First instruction should be a right shift of a multiply.
52987-
if (Src.getOpcode() != ISD::SRL ||
52988-
Src.getOperand(0).getOpcode() != ISD::MUL)
52989-
return SDValue();
52986+
using namespace llvm::SDPatternMatch;
5299052987

5299152988
if (!Subtarget.hasSSE2())
5299252989
return SDValue();
@@ -53001,15 +52998,12 @@ static SDValue combinePMULH(SDValue Src, EVT VT, const SDLoc &DL,
5300152998
if (InVT.getVectorElementType().getSizeInBits() < 32)
5300252999
return SDValue();
5300353000

53004-
// Need a shift by 16.
53005-
APInt ShiftAmt;
53006-
if (!ISD::isConstantSplatVector(Src.getOperand(1).getNode(), ShiftAmt) ||
53007-
ShiftAmt != 16)
53001+
// First instruction should be a right shift by 16 of a multiply.
53002+
SDValue LHS, RHS;
53003+
if (!sd_match(Src,
53004+
m_Srl(m_Mul(m_Value(LHS), m_Value(RHS)), m_SpecificInt(16))))
5300853005
return SDValue();
5300953006

53010-
SDValue LHS = Src.getOperand(0).getOperand(0);
53011-
SDValue RHS = Src.getOperand(0).getOperand(1);
53012-
5301353007
// Count leading sign/zero bits on both inputs - if there are enough then
5301453008
// truncation back to vXi16 will be cheap - either as a pack/shuffle
5301553009
// sequence or using AVX512 truncations. If the inputs are sext/zext then the

0 commit comments

Comments
 (0)