[llvm] Add SD matchers and unit test coverage for ISD::VECTOR_SHUFFLE (PR #119592)
Aidan Goldfarb via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 25 07:34:50 PST 2024
================
@@ -133,13 +134,11 @@ TEST_F(SelectionDAGPatternMatchTest, matchVecShuffle) {
DAG->getVectorShuffle(VInt32VT, DL, V0, V1, MaskData);
using namespace SDPatternMatch;
+ EXPECT_TRUE(sd_match(VecShuffleWithMask, m_Shuffle(m_Value(), m_Value())));
EXPECT_TRUE(sd_match(VecShuffleWithMask,
- m_Shuffle(m_Value(), m_Value(), CapturedMask)));
+ m_Shuffle(m_Value(), m_Value(), m_Mask(CapturedMask))));
EXPECT_TRUE(sd_match(VecShuffleWithMask,
- m_ShuffleSpecificMask(m_Value(), m_Value(), MaskData)));
- EXPECT_FALSE(
- sd_match(VecShuffleWithMask,
- m_ShuffleSpecificMask(m_Value(), m_Value(), OtherMaskData)));
+ m_Shuffle(m_Value(), m_Value(), m_SpecificMask(Mask))));
EXPECT_TRUE(std::equal(MaskData.begin(), MaskData.end(), CapturedMask.begin(),
CapturedMask.end()));
EXPECT_FALSE(std::equal(OtherMaskData.begin(), OtherMaskData.end(),
----------------
AidanGoldfarb wrote:
I added the test you suggested, which does `MaskData == OtherMaskData` inside of `m_SpecificMask`. However is the other negative test, which does effectively `CaptureMask==OtherMaskData`, not still desired to check that the mask was successfully captured by `m_Mask`? It is tested for equality with the test above `MaskData==CaptureMask`, but in the case of an empty mask or an incorrect equality comparison (as I mistakenly implemented before) should we keep it around? I am not very sure of the coding standards of how much overlap can exist between tests before one is deleted.
https://github.com/llvm/llvm-project/pull/119592
More information about the llvm-commits
mailing list