Skip to content

Commit f408692

Browse files
author
v01dxyz
committed
[DAG] Add m_Ctlz to SDPatternMatch.h
1 parent bcdeb90 commit f408692

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

llvm/include/llvm/CodeGen/SDPatternMatch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,10 @@ template <typename Opnd> inline UnaryOpc_match<Opnd> m_FPToSI(const Opnd &Op) {
751751
return UnaryOpc_match<Opnd>(ISD::FP_TO_SINT, Op);
752752
}
753753

754+
template <typename Opnd> inline UnaryOpc_match<Opnd> m_Ctlz(const Opnd &Op) {
755+
return UnaryOpc_match<Opnd>(ISD::CTLZ, Op);
756+
}
757+
754758
// === Constants ===
755759
struct ConstantInt_match {
756760
APInt *BindVal;

llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ TEST_F(SelectionDAGPatternMatchTest, matchUnaryOp) {
257257
SDValue FPToSI = DAG->getNode(ISD::FP_TO_SINT, DL, FloatVT, Op2);
258258
SDValue FPToUI = DAG->getNode(ISD::FP_TO_UINT, DL, FloatVT, Op2);
259259

260+
SDValue Ctlz = DAG->getNode(ISD::CTLZ, DL, Int32VT, Op0);
261+
260262
using namespace SDPatternMatch;
261263
EXPECT_TRUE(sd_match(ZExt, m_UnaryOp(ISD::ZERO_EXTEND, m_Value())));
262264
EXPECT_TRUE(sd_match(SExt, m_SExt(m_Value())));
@@ -273,6 +275,8 @@ TEST_F(SelectionDAGPatternMatchTest, matchUnaryOp) {
273275
EXPECT_TRUE(sd_match(FPToSI, m_FPToSI(m_Value())));
274276
EXPECT_FALSE(sd_match(FPToUI, m_FPToSI(m_Value())));
275277
EXPECT_FALSE(sd_match(FPToSI, m_FPToUI(m_Value())));
278+
279+
EXPECT_TRUE(sd_match(Ctlz, m_Ctlz(m_Value())));
276280
}
277281

278282
TEST_F(SelectionDAGPatternMatchTest, matchConstants) {

0 commit comments

Comments
 (0)