[Mlir-commits] [mlir] e00cbbe - [MLIR][Presburger] Cleanup getMaybeValues in FACV
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue May 17 21:14:59 PDT 2022
Author: Groverkss
Date: 2022-05-18T09:44:14+05:30
New Revision: e00cbbec06c08dc616a0d52a20f678b8fbd4e304
URL: https://github.com/llvm/llvm-project/commit/e00cbbec06c08dc616a0d52a20f678b8fbd4e304
DIFF: https://github.com/llvm/llvm-project/commit/e00cbbec06c08dc616a0d52a20f678b8fbd4e304.diff
LOG: [MLIR][Presburger] Cleanup getMaybeValues in FACV
This patch cleans up multiple getMaybeValue functions to take an IdKind instead
of special functions.
Reviewed By: arjunp
Differential Revision: https://reviews.llvm.org/D125617
Added:
Modified:
mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h b/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
index 0ddacad04792e..b307f0d4d2e33 100644
--- a/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
+++ b/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
@@ -431,16 +431,11 @@ class FlatAffineValueConstraints : public presburger::IntegerPolyhedron {
return {values.data(), values.size()};
}
- inline ArrayRef<Optional<Value>> getMaybeDimValues() const {
- return {values.data(), getNumDimIds()};
- }
-
- inline ArrayRef<Optional<Value>> getMaybeSymbolValues() const {
- return {values.data() + getNumDimIds(), getNumSymbolIds()};
- }
-
- inline ArrayRef<Optional<Value>> getMaybeDimAndSymbolValues() const {
- return {values.data(), getNumDimIds() + getNumSymbolIds()};
+ inline ArrayRef<Optional<Value>>
+ getMaybeValues(presburger::IdKind kind) const {
+ assert(kind != IdKind::Local &&
+ "Local identifiers do not have any value attached to them.");
+ return {values.data() + getIdKindOffset(kind), getNumIdKind(kind)};
}
/// Sets the Value associated with the pos^th identifier.
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
index b3bf543f93dc5..2c8e3acacb4da 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
@@ -1666,8 +1666,8 @@ void FlatAffineRelation::compose(const FlatAffineRelation &other) {
convertToLocal(IdKind::SetDim, getNumDomainDims() - removeDims,
getNumDomainDims());
- auto thisMaybeValues = getMaybeDimValues();
- auto relMaybeValues = rel.getMaybeDimValues();
+ auto thisMaybeValues = getMaybeValues(IdKind::SetDim);
+ auto relMaybeValues = rel.getMaybeValues(IdKind::SetDim);
// Add and match domain of `rel` to domain of `this`.
for (unsigned i = 0, e = rel.getNumDomainDims(); i < e; ++i)
diff --git a/mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp b/mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
index 78ad8532e0f3f..5abc780e22d8e 100644
--- a/mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
+++ b/mlir/lib/Dialect/SCF/Utils/AffineCanonicalizationUtils.cpp
@@ -43,8 +43,8 @@ static LogicalResult alignAndAddBound(FlatAffineValueConstraints &constraints,
unsigned pos, AffineMap map,
ValueRange operands) {
SmallVector<Value> dims, syms, newSyms;
- unpackOptionalValues(constraints.getMaybeDimValues(), dims);
- unpackOptionalValues(constraints.getMaybeSymbolValues(), syms);
+ unpackOptionalValues(constraints.getMaybeValues(IdKind::SetDim), dims);
+ unpackOptionalValues(constraints.getMaybeValues(IdKind::Symbol), syms);
AffineMap alignedMap =
alignAffineMapWithValues(map, operands, dims, syms, &newSyms);
@@ -182,7 +182,7 @@ canonicalizeMinMaxOp(RewriterBase &rewriter, Operation *op, AffineMap map,
// Lower and upper bound of `op` are equal. Replace `minOp` with its bound.
AffineMap newMap = alignedBoundMap;
SmallVector<Value> newOperands;
- unpackOptionalValues(constraints.getMaybeDimAndSymbolValues(), newOperands);
+ unpackOptionalValues(constraints.getMaybeValues(), newOperands);
// If dims/symbols have known constant values, use those in order to simplify
// the affine map further.
for (int64_t i = 0, e = constraints.getNumIds(); i < e; ++i) {
More information about the Mlir-commits
mailing list