[llvm] ad77888 - [DAG] Add SDPatternMatch for VScale nodes
Michael Maitland via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 06:52:41 PDT 2024
Author: Michael Maitland
Date: 2024-07-29T06:50:26-07:00
New Revision: ad778889cf5ce74be3193fae1d3b2bce34a56863
URL: https://github.com/llvm/llvm-project/commit/ad778889cf5ce74be3193fae1d3b2bce34a56863
DIFF: https://github.com/llvm/llvm-project/commit/ad778889cf5ce74be3193fae1d3b2bce34a56863.diff
LOG: [DAG] Add SDPatternMatch for VScale nodes
Added:
Modified:
llvm/include/llvm/CodeGen/SDPatternMatch.h
llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/SDPatternMatch.h b/llvm/include/llvm/CodeGen/SDPatternMatch.h
index 966e04f21334d..6ac1aaa01d912 100644
--- a/llvm/include/llvm/CodeGen/SDPatternMatch.h
+++ b/llvm/include/llvm/CodeGen/SDPatternMatch.h
@@ -728,6 +728,10 @@ inline Or<UnaryOpc_match<Opnd>, Opnd> m_TruncOrSelf(const Opnd &Op) {
return Or<UnaryOpc_match<Opnd>, Opnd>(m_Trunc(Op), Op);
}
+template <typename Opnd> inline UnaryOpc_match<Opnd> m_VScale(const Opnd &Op) {
+ return UnaryOpc_match<Opnd>(ISD::VSCALE, Op);
+}
+
// === Constants ===
struct ConstantInt_match {
APInt *BindVal;
diff --git a/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp b/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp
index 549931b57e9af..2fa8fbb523784 100644
--- a/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp
+++ b/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp
@@ -241,6 +241,8 @@ TEST_F(SelectionDAGPatternMatchTest, matchUnaryOp) {
SDValue Neg = DAG->getNegative(Op0, DL, Int32VT);
SDValue Not = DAG->getNOT(DL, Op0, Int32VT);
+ SDValue VScale = DAG->getVScale(DL, Int32VT, APInt::getMaxValue(32));
+
using namespace SDPatternMatch;
EXPECT_TRUE(sd_match(ZExt, m_UnaryOp(ISD::ZERO_EXTEND, m_Value())));
EXPECT_TRUE(sd_match(SExt, m_SExt(m_Value())));
@@ -251,6 +253,7 @@ TEST_F(SelectionDAGPatternMatchTest, matchUnaryOp) {
EXPECT_FALSE(sd_match(ZExt, m_Neg(m_Value())));
EXPECT_FALSE(sd_match(Sub, m_Neg(m_Value())));
EXPECT_FALSE(sd_match(Neg, m_Not(m_Value())));
+ EXPECT_TRUE(sd_match(VScale, m_VScale(m_Value())));
}
TEST_F(SelectionDAGPatternMatchTest, matchConstants) {
More information about the llvm-commits
mailing list