[llvm] [SelectionDAG] Add m_Neg and m_Not pattern matcher and update DAGCombiner (PR #85365)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 15 02:53:25 PDT 2024


================
@@ -174,10 +174,18 @@ TEST_F(SelectionDAGPatternMatchTest, matchUnaryOp) {
   SDValue SExt = DAG->getNode(ISD::SIGN_EXTEND, DL, Int64VT, Op0);
   SDValue Trunc = DAG->getNode(ISD::TRUNCATE, DL, Int32VT, Op1);
 
+  SDValue Zero = DAG->getConstant(0, DL, Int32VT);
+  SDValue AllOnes = DAG->getConstant(APInt::getAllOnes(32), DL, Int32VT);
+  SDValue Neg = DAG->getNode(ISD::SUB, DL, Int32VT, Zero, Op0);
+  SDValue Not = DAG->getNode(ISD::XOR, DL, Int32VT, AllOnes, Op0);
----------------
ZiCong-Wang wrote:

Got it. The same to DAG->getNegative.

https://github.com/llvm/llvm-project/pull/85365


More information about the llvm-commits mailing list