Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down