[llvm] [SelectionDAG] Add m_Neg and m_Not pattern matcher and update DAGCombiner (PR #85365)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 15 15:18:52 PDT 2024
================
@@ -174,10 +174,19 @@ TEST_F(SelectionDAGPatternMatchTest, matchUnaryOp) {
SDValue SExt = DAG->getNode(ISD::SIGN_EXTEND, DL, Int64VT, Op0);
SDValue Trunc = DAG->getNode(ISD::TRUNCATE, DL, Int32VT, Op1);
+ SDValue Neg = DAG->getNegative(Op0, DL, Int32VT);
+ SDValue Not = DAG->getNOT(DL, Op0, Int32VT);
+
using namespace SDPatternMatch;
EXPECT_TRUE(sd_match(ZExt, m_UnaryOp(ISD::ZERO_EXTEND, m_Value())));
EXPECT_TRUE(sd_match(SExt, m_SExt(m_Value())));
EXPECT_TRUE(sd_match(Trunc, m_Trunc(m_Specific(Op1))));
+
+ EXPECT_TRUE(sd_match(Neg, m_Neg(m_Value())));
+ EXPECT_TRUE(sd_match(Not, m_Not(m_Value())));
+ EXPECT_FALSE(sd_match(Neg, m_Node(ISD::SUB, m_Value())));
----------------
mshockwave wrote:
I think what Matt meant was EXPECT_FALSE test against your new m_Neg and m_Not. For instance, check if `sd_match(ZExt, m_Neg(...))` is false.
https://github.com/llvm/llvm-project/pull/85365
More information about the llvm-commits
mailing list