Skip to content

Add SD matchers and unit test coverage for ISD::VECTOR_SHUFFLE #119592

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

Merged
merged 17 commits into from
Jan 6, 2025

Conversation

AidanGoldfarb
Copy link
Contributor

@AidanGoldfarb AidanGoldfarb commented Dec 11, 2024

This PR resolves #118845. I aimed to mirror the implementation m_Shuffle() in PatternMatch.h.

Updated SDPatternMatch.h

  • Added struct m_Mask to match masks (ArrayRef<int>)
  • Added two m_Shuffle functions. One to match independently of mask, and one to match considering mask.
  • Added struct SDShuffle_match to match ISD::VECTOR_SHUFFLE considering mask

Updated SDPatternMatchTest.cpp

  • Added matchVecShuffle test, which tests the behavior of both m_Shuffle() functions

I am not sure if my test coverage is complete. I am not sure how to test a false match, simply test against a different instruction? Other tests , such as for VSelect, test against Select. I am not sure if there is an analogous instruction to compare against for VECTOR_SHUFFLE. I would appreciate some pointers in this area. In general, please liberally critique this PR!

@AidanGoldfarb AidanGoldfarb marked this pull request as ready for review December 11, 2024 21:55
@AidanGoldfarb AidanGoldfarb changed the title Added SD matchers and unit test coverage for ISD::VECTOR_SHUFFLE Add SD matchers and unit test coverage for ISD::VECTOR_SHUFFLE Dec 11, 2024
@RKSimon RKSimon requested a review from mshockwave December 12, 2024 14:02
…Mask.match() with a std::equal(mask,i->getMask(). changed matchVecShuffle test to not initialize Mask. Also added a test to compare contents of MaskData to Mask.
Copy link

github-actions bot commented Dec 12, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

…res mask as &arrayref. Snd matches specific contents as arrayref. Removed m_mask, updated tests
…equal(). Readded cmp for capture test. Removed const for ArrayRef. Correctly capture arrayref in m_Shuffle varient. Changed m_Value(V) to m_Value, as vec contents not needed.
Copy link
Member

@mshockwave mshockwave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM w/ minor comments.

@mshockwave
Copy link
Member

Feel free to merge it when the merge conflicts are fixed.

@RKSimon
Copy link
Collaborator

RKSimon commented Dec 20, 2024

Thanks @AidanGoldfarb

@topperc
Copy link
Collaborator

topperc commented Dec 20, 2024

I kind of think we should have separate m_Shuffle and m_Mask/m_SpecificMask like IR. That will allow more m_*Mask to be added in the future without needing to duplicate all of the code. For example, we may want one that takes a function_ref to do custom matching. The IR match function for m_Mask/m_SpecificMask takes an ArrayRef<int> Mask as its argument.

@RKSimon
Copy link
Collaborator

RKSimon commented Dec 23, 2024

@AidanGoldfarb Do you think we could keep closer to the PatternMatch approach of m_Shuffle / m_Mask / m_SpecificMask (and m_SplatOrPoisonMask / m_ZeroMask .....) ?

@AidanGoldfarb
Copy link
Contributor Author

I just pushed some changes that mirror the PatternMatch approach as closely as possible. This includes
m_Mask and m_SpecificMask, with room to add things like m_ZeroMask. I did not add m_ZeroMask or m_SplatOrPoisonMask but would be happy to do it if there is a use case.

Copy link
Member

@mshockwave mshockwave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
@topperc do you have any other comments?

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AidanGoldfarb AidanGoldfarb merged commit f3bc8c3 into llvm:main Jan 6, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DAG] SDPatternMatch - add m_Shuffle matcher
4 participants