Skip to content

Commit ad77888

Browse files
[DAG] Add SDPatternMatch for VScale nodes
1 parent f7e9d48 commit ad77888

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

llvm/include/llvm/CodeGen/SDPatternMatch.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,10 @@ inline Or<UnaryOpc_match<Opnd>, Opnd> m_TruncOrSelf(const Opnd &Op) {
728728
return Or<UnaryOpc_match<Opnd>, Opnd>(m_Trunc(Op), Op);
729729
}
730730

731+
template <typename Opnd> inline UnaryOpc_match<Opnd> m_VScale(const Opnd &Op) {
732+
return UnaryOpc_match<Opnd>(ISD::VSCALE, Op);
733+
}
734+
731735
// === Constants ===
732736
struct ConstantInt_match {
733737
APInt *BindVal;

llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ TEST_F(SelectionDAGPatternMatchTest, matchUnaryOp) {
241241
SDValue Neg = DAG->getNegative(Op0, DL, Int32VT);
242242
SDValue Not = DAG->getNOT(DL, Op0, Int32VT);
243243

244+
SDValue VScale = DAG->getVScale(DL, Int32VT, APInt::getMaxValue(32));
245+
244246
using namespace SDPatternMatch;
245247
EXPECT_TRUE(sd_match(ZExt, m_UnaryOp(ISD::ZERO_EXTEND, m_Value())));
246248
EXPECT_TRUE(sd_match(SExt, m_SExt(m_Value())));
@@ -251,6 +253,7 @@ TEST_F(SelectionDAGPatternMatchTest, matchUnaryOp) {
251253
EXPECT_FALSE(sd_match(ZExt, m_Neg(m_Value())));
252254
EXPECT_FALSE(sd_match(Sub, m_Neg(m_Value())));
253255
EXPECT_FALSE(sd_match(Neg, m_Not(m_Value())));
256+
EXPECT_TRUE(sd_match(VScale, m_VScale(m_Value())));
254257
}
255258

256259
TEST_F(SelectionDAGPatternMatchTest, matchConstants) {

0 commit comments

Comments
 (0)