[llvm] [DAG] SDPatternMatch - add m_Negative/m_StrictlyPositive/m_NonNegative/m_NonPositive/m_NonZero matchers (PR #175191)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 12 02:30:49 PST 2026
================
@@ -1182,6 +1173,46 @@ inline SpecificFP_match m_SpecificFP(double V) {
return SpecificFP_match(APFloat(V));
}
+struct Negative_match {
+ template <typename MatchContext>
+ bool match(const MatchContext &M, SDValue N) const {
+ const SelectionDAG *DAG = M.getDAG();
+ return DAG ? DAG->IsNegative(N) : false;
+ }
+};
+
+struct NonNegative_match {
+ template <typename MatchContext>
+ bool match(const MatchContext &M, SDValue N) const {
+ const SelectionDAG *DAG = M.getDAG();
+ return DAG ? DAG->IsNonNegative(N) : false;
+ }
+};
+
+struct StrictlyPositive_match {
+ template <typename MatchContext>
+ bool match(const MatchContext &M, SDValue N) const {
+ const SelectionDAG *DAG = M.getDAG();
+ return DAG ? DAG->IsStrictlyPositive(N) : false;
+ }
+};
+
+struct NonPositive_match {
+ template <typename MatchContext>
+ bool match(const MatchContext &M, SDValue N) const {
+ const SelectionDAG *DAG = M.getDAG();
+ return DAG ? DAG->IsNonPositive(N) : false;
----------------
RKSimon wrote:
```suggestion
return DAG && DAG->IsNonPositivetlyPositive(N);
```
https://github.com/llvm/llvm-project/pull/175191
More information about the llvm-commits
mailing list