From 28f8634b6edf534f737e9c8ec4c68ad5b5d2aea1 Mon Sep 17 00:00:00 2001 From: Aditya Nandakumar <aditya_nandakumar@apple.com> Date: Fri, 23 Feb 2018 01:01:59 +0000 Subject: [PATCH] [GISel]: Fix base case for m_any_of PatternMatcher. The base case for any_of was incorrectly returning true. Also add test case which uses m_any_of(preds...) where none of the predicates are true. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325848 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/GlobalISel/MIPatternMatch.h | 2 +- unittests/CodeGen/GlobalISel/PatternMatchTest.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h b/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h index 8adeb4969e6..e3302217696 100644 --- a/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h +++ b/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h @@ -93,7 +93,7 @@ struct And<Pred, Preds...> : And<Preds...> { template <typename... Preds> struct Or { template <typename MatchSrc> bool match(MachineRegisterInfo &MRI, MatchSrc &&src) { - return true; + return false; } }; diff --git a/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp b/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp index b4281013350..aa185278f59 100644 --- a/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp +++ b/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp @@ -368,6 +368,12 @@ TEST(PatternMatchInstr, MatchCombinators) { ASSERT_TRUE(match); ASSERT_EQ(Src0, Copies[0]); ASSERT_EQ(Src1, Copies[1]); + + // Match a case where none of the predicates hold true. + match = mi_match( + MIBAdd->getOperand(0).getReg(), MRI, + m_any_of(m_SpecificType(LLT::scalar(16)), m_GSub(m_Reg(), m_Reg()))); + ASSERT_FALSE(match); } } // namespace -- GitLab