Skip to content

Commit 0437895

Browse files
committed
[X86] combineShiftToPMULH - convert matching to use SDPatternMatch. NFC.
1 parent 222e795 commit 0437895

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49838,31 +49838,24 @@ static SDValue combineMul(SDNode *N, SelectionDAG &DAG,
4983849838
static SDValue combineShiftToPMULH(SDNode *N, SelectionDAG &DAG,
4983949839
const SDLoc &DL,
4984049840
const X86Subtarget &Subtarget) {
49841+
using namespace SDPatternMatch;
4984149842
assert((N->getOpcode() == ISD::SRL || N->getOpcode() == ISD::SRA) &&
49842-
"SRL or SRA node is required here!");
49843+
"SRL or SRA node is required here!");
4984349844

4984449845
if (!Subtarget.hasSSE2())
4984549846
return SDValue();
4984649847

49847-
// The operation feeding into the shift must be a multiply.
49848-
SDValue ShiftOperand = N->getOperand(0);
49849-
if (ShiftOperand.getOpcode() != ISD::MUL || !ShiftOperand.hasOneUse())
49850-
return SDValue();
49851-
4985249848
// Input type should be at least vXi32.
4985349849
EVT VT = N->getValueType(0);
4985449850
if (!VT.isVector() || VT.getVectorElementType().getSizeInBits() < 32)
4985549851
return SDValue();
4985649852

49857-
// Need a shift by 16.
49858-
APInt ShiftAmt;
49859-
if (!ISD::isConstantSplatVector(N->getOperand(1).getNode(), ShiftAmt) ||
49860-
ShiftAmt != 16)
49853+
// The operation must be a multiply shifted right by 16.
49854+
SDValue LHS, RHS;
49855+
if (!sd_match(N->getOperand(1), m_SpecificInt(16)) ||
49856+
!sd_match(N->getOperand(0), m_OneUse(m_Mul(m_Value(LHS), m_Value(RHS)))))
4986149857
return SDValue();
4986249858

49863-
SDValue LHS = ShiftOperand.getOperand(0);
49864-
SDValue RHS = ShiftOperand.getOperand(1);
49865-
4986649859
unsigned ExtOpc = LHS.getOpcode();
4986749860
if ((ExtOpc != ISD::SIGN_EXTEND && ExtOpc != ISD::ZERO_EXTEND) ||
4986849861
RHS.getOpcode() != ExtOpc)

0 commit comments

Comments
 (0)