[Mlir-commits] [mlir] d4b41b9 - [mlir] Consolidate two implementations of meet (NFC) (#167208)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Nov 9 10:31:13 PST 2025


Author: Kazu Hirata
Date: 2025-11-09T10:31:10-08:00
New Revision: d4b41b9de091b39525fdf3fcbf1b86a3895fbc48

URL: https://github.com/llvm/llvm-project/commit/d4b41b9de091b39525fdf3fcbf1b86a3895fbc48
DIFF: https://github.com/llvm/llvm-project/commit/d4b41b9de091b39525fdf3fcbf1b86a3895fbc48.diff

LOG: [mlir] Consolidate two implementations of meet (NFC) (#167208)

This patch consolidates two implementations of meet using
"if constexpr", migrating away from the SFINAE-based approach.

Added: 
    

Modified: 
    mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h b/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
index 985573476ab78..360d3c7e62000 100644
--- a/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
+++ b/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
@@ -138,28 +138,25 @@ class Lattice : public AbstractSparseLattice {
 
   /// Meet (intersect) the information contained in the 'rhs' value with this
   /// lattice. Returns if the state of the current lattice changed.  If the
-  /// lattice elements don't have a `meet` method, this is a no-op (see below.)
-  template <typename VT,
-            std::enable_if_t<lattice_has_meet<VT>::value> * = nullptr>
+  /// lattice elements don't have a `meet` method, this is a no-op.
+  template <typename VT>
   ChangeResult meet(const VT &rhs) {
-    ValueT newValue = ValueT::meet(value, rhs);
-    assert(ValueT::meet(newValue, value) == newValue &&
-           "expected `meet` to be monotonic");
-    assert(ValueT::meet(newValue, rhs) == newValue &&
-           "expected `meet` to be monotonic");
-
-    // Update the current optimistic value if something changed.
-    if (newValue == value)
+    if constexpr (!lattice_has_meet<VT>::value) {
       return ChangeResult::NoChange;
-
-    value = newValue;
-    return ChangeResult::Change;
-  }
-
-  template <typename VT,
-            std::enable_if_t<!lattice_has_meet<VT>::value> * = nullptr>
-  ChangeResult meet(const VT &rhs) {
-    return ChangeResult::NoChange;
+    } else {
+      ValueT newValue = ValueT::meet(value, rhs);
+      assert(ValueT::meet(newValue, value) == newValue &&
+             "expected `meet` to be monotonic");
+      assert(ValueT::meet(newValue, rhs) == newValue &&
+             "expected `meet` to be monotonic");
+
+      // Update the current optimistic value if something changed.
+      if (newValue == value)
+        return ChangeResult::NoChange;
+
+      value = newValue;
+      return ChangeResult::Change;
+    }
   }
 
   /// Print the lattice element.


        


More information about the Mlir-commits mailing list