-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[mlir] Consolidate two implementations of meet (NFC) #167208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[mlir] Consolidate two implementations of meet (NFC) #167208
Conversation
This patch consolidates two implementations of meet using "if constexpr", migrating away from the SFINAE-based approach.
|
@llvm/pr-subscribers-mlir Author: Kazu Hirata (kazutakahirata) ChangesThis patch consolidates two implementations of meet using Full diff: https://github.com/llvm/llvm-project/pull/167208.diff 1 Files Affected:
diff --git a/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h b/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
index 985573476ab78..89da84346c109 100644
--- a/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
+++ b/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h
@@ -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) {
+ 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;
+ }
- template <typename VT,
- std::enable_if_t<!lattice_has_meet<VT>::value> * = nullptr>
- ChangeResult meet(const VT &rhs) {
return ChangeResult::NoChange;
}
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/52/builds/12692 Here is the relevant piece of the build log for the reference |
This patch consolidates two implementations of meet using
"if constexpr", migrating away from the SFINAE-based approach.