[llvm] r325848 - [GISel]: Fix base case for m_any_of PatternMatcher.
Aditya Nandakumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 22 17:01:59 PST 2018
Author: aditya_nandakumar
Date: Thu Feb 22 17:01:59 2018
New Revision: 325848
URL: http://llvm.org/viewvc/llvm-project?rev=325848&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
llvm/trunk/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h?rev=325848&r1=325847&r2=325848&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h Thu Feb 22 17:01:59 2018
@@ -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;
}
};
Modified: llvm/trunk/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp?rev=325848&r1=325847&r2=325848&view=diff
==============================================================================
--- llvm/trunk/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp (original)
+++ llvm/trunk/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp Thu Feb 22 17:01:59 2018
@@ -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
More information about the llvm-commits
mailing list