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 ::value> * = nullptr> + /// lattice elements don't have a `meet` method, this is a no-op. + template 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::value) { return ChangeResult::NoChange; - - value = newValue; - return ChangeResult::Change; - } - - template ::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.