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

Kazu Hirata llvmlistbot at llvm.org
Sun Nov 9 08:36:51 PST 2025


================
@@ -138,27 +138,24 @@ 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)
-      return ChangeResult::NoChange;
-
-    value = newValue;
-    return ChangeResult::Change;
-  }
+    if constexpr (lattice_has_meet<VT>::value) {
----------------
kazutakahirata wrote:

Yes, is something like this OK?

```
if constexpr (!lattice_has_meet<VT>::value) {
  return ChangeResult::NoChange;
} else {
  ...
}
```

I have to have `else` because I need `if constexpr` to drop the call to `ValueT::meet`.


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


More information about the Mlir-commits mailing list