-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SDPatternMatch] Add matchers m_ExtractSubvector and m_InsertSubvector #120212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@cheezeburglar Sorry I missed this over the Christmas break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minors @mshockwave WDYT?
@@ -802,6 +808,12 @@ inline BinaryOpc_match<LHS, RHS> m_ExtractElt(const LHS &Vec, const RHS &Idx) { | |||
return BinaryOpc_match<LHS, RHS>(ISD::EXTRACT_VECTOR_ELT, Vec, Idx); | |||
} | |||
|
|||
template <typename LHS, typename RHS> | |||
inline BinaryOpc_match<LHS, RHS> m_ExtractSubvector(const LHS &L, | |||
const RHS &R) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(pedantic) replace L and R with Vec and Idx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, in subsequent commit
EXPECT_TRUE( | ||
sd_match(SubVec, m_ExtractSubvector(m_Specific(Vec), m_Specific(Idx0)))); | ||
EXPECT_TRUE(sd_match(SubVec, m_BinOp(ISD::EXTRACT_SUBVECTOR, m_Specific(Vec), | ||
m_Specific(Idx0)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can you add true/false tests with a m_SpecificInt() for the index as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, in subsequent commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only has a minor comment, otherwise lgtm
EXPECT_TRUE( | ||
sd_match(SubVec, m_BinOp(ISD::EXTRACT_SUBVECTOR, m_Value(), m_Value()))); | ||
EXPECT_TRUE( | ||
sd_match(SubVec, m_ExtractSubvector(m_Specific(Vec), m_Specific(Idx0)))); | ||
EXPECT_TRUE(sd_match(SubVec, m_BinOp(ISD::EXTRACT_SUBVECTOR, m_Specific(Vec), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we really need the checks with m_BinOp
here. m_ExtractSubvector
should suffice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, in subsequent commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - cheers
You can test this locally with the following command:git-clang-format --diff 300deebf41d2da96701fe29c0faa8025b7efa120 f1a7cc99b45f42a5699c0464eabb1ec72cd3f967 --extensions cpp,h -- llvm/include/llvm/CodeGen/SDPatternMatch.h llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp View the diff from clang-format here.diff --git a/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp b/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp
index 81ba3171c8..31d7414d3e 100644
--- a/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp
+++ b/llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp
@@ -203,7 +203,6 @@ TEST_F(SelectionDAGPatternMatchTest, matchTernaryOp) {
EXPECT_FALSE(sd_match(
InsertSubvector,
m_InsertSubvector(m_Specific(V2), m_Specific(V3), m_SpecificInt(3))));
-
}
TEST_F(SelectionDAGPatternMatchTest, matchBinaryOp) {
|
EXPECT_FALSE(sd_match( | ||
InsertSubvector, | ||
m_InsertSubvector(m_Specific(V2), m_Specific(V3), m_SpecificInt(3)))); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cheezeburglar could you remove this empty line to make clang-format happy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mea culpa - I think the latest commit should make it pass the linter. On my machine
$ git-clang-format --diff 300deebf41d2da96701fe29c0faa8025b7efa120 f1a7cc99b45f42a5699c0464eabb1ec72cd3f967 --extensions cpp,h -- llvm/include/llvm/CodeGen/SDPatternMatch.h llvm/unittests/CodeGen/SelectionDAGPatternMatchTest.cpp
produces no output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM congrats!
@cheezeburglar Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Fixes #118846