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

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 15 02:51:05 PDT 2024


================
@@ -705,6 +705,20 @@ inline auto m_False() {
       },
       m_Value()};
 }
+
+/// Match a negtive as a sub(0, v)
+template <typename ValTy>
+inline BinaryOpc_match<SpecificInt_match, ValTy>
+m_Neg(const ValTy &V) {
+  return m_Sub(m_Zero(), V);
+}
+
+/// Match a Not as a xor(v, 1) or xor(1, v)
----------------
jayfoad wrote:

```suggestion
/// Match a Not as a xor(v, -1) or xor(-1, v)
```
Or `~0`

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


More information about the llvm-commits mailing list