diff --git a/mlir/include/mlir/Analysis/Presburger/Utils.h b/mlir/include/mlir/Analysis/Presburger/Utils.h --- a/mlir/include/mlir/Analysis/Presburger/Utils.h +++ b/mlir/include/mlir/Analysis/Presburger/Utils.h @@ -31,6 +31,7 @@ /// and `upperBoundIdx` is set. By default the kind attribute is set to None. struct MaybeLocalRepr { ReprKind kind = ReprKind::None; + explicit operator bool() const { return kind != ReprKind::None; } union { unsigned equalityIdx; struct { diff --git a/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp b/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp --- a/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp +++ b/mlir/lib/Analysis/Presburger/IntegerPolyhedron.cpp @@ -864,9 +864,9 @@ changed = false; for (unsigned i = 0, e = getNumLocalIds(); i < e; ++i) { if (!foundRepr[i + divOffset]) { - auto res = computeSingleVarRepr(*this, foundRepr, divOffset + i, - dividends[i], denominators[i]); - if (res.kind == ReprKind::None) + MaybeLocalRepr res = computeSingleVarRepr( + *this, foundRepr, divOffset + i, dividends[i], denominators[i]); + if (!res) continue; foundRepr[i + divOffset] = true; repr[i] = res; @@ -878,7 +878,7 @@ // Set 0 denominator for identifiers for which no division representation // could be found. for (unsigned i = 0, e = repr.size(); i < e; ++i) - if (repr[i].kind == ReprKind::None) + if (!repr[i]) denominators[i] = 0; }