[Mlir-commits] [mlir] c19c51e - [mlir][Analysis][NFC] Clean up FlatAffineValueConstraints

Matthias Springer llvmlistbot at llvm.org
Mon Aug 16 18:39:25 PDT 2021


Author: Matthias Springer
Date: 2021-08-17T10:38:57+09:00
New Revision: c19c51e357a2e15e391e547441291f8a2ff771f9

URL: https://github.com/llvm/llvm-project/commit/c19c51e357a2e15e391e547441291f8a2ff771f9
DIFF: https://github.com/llvm/llvm-project/commit/c19c51e357a2e15e391e547441291f8a2ff771f9.diff

LOG: [mlir][Analysis][NFC] Clean up FlatAffineValueConstraints

* Rename ids to values in FlatAffineValueConstraints.
* Overall cleanup of comments in FlatAffineConstraints and FlatAffineValueConstraints.

Differential Revision: https://reviews.llvm.org/D107947

Added: 
    

Modified: 
    mlir/include/mlir/Analysis/AffineStructures.h
    mlir/lib/Analysis/AffineAnalysis.cpp
    mlir/lib/Analysis/AffineStructures.cpp
    mlir/lib/Analysis/Utils.cpp
    mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
    mlir/lib/Transforms/LoopFusion.cpp
    mlir/lib/Transforms/Utils/LoopUtils.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Analysis/AffineStructures.h b/mlir/include/mlir/Analysis/AffineStructures.h
index c97a2f6493eed..76f62355d9af8 100644
--- a/mlir/include/mlir/Analysis/AffineStructures.h
+++ b/mlir/include/mlir/Analysis/AffineStructures.h
@@ -116,7 +116,7 @@ class FlatAffineConstraints {
   void reset(unsigned numDims = 0, unsigned numSymbols = 0,
              unsigned numLocals = 0);
 
-  /// Appends constraints from 'other' into this. This is equivalent to an
+  /// Appends constraints from `other` into `this`. This is equivalent to an
   /// intersection with no simplification of any sort attempted.
   void append(const FlatAffineConstraints &other);
 
@@ -127,14 +127,15 @@ class FlatAffineConstraints {
   /// Returns false otherwise.
   bool isEmpty() const;
 
-  /// Runs the GCD test on all equality constraints. Returns 'true' if this test
-  /// fails on any equality. Returns 'false' otherwise.
+  /// Runs the GCD test on all equality constraints. Returns true if this test
+  /// fails on any equality. Returns false otherwise.
   /// This test can be used to disprove the existence of a solution. If it
   /// returns true, no integer solution to the equality constraints can exist.
   bool isEmptyByGCDTest() const;
 
   /// Returns true if the set of constraints is found to have no solution,
-  /// false if a solution exists. Uses the same algorithm as findIntegerSample.
+  /// false if a solution exists. Uses the same algorithm as
+  /// `findIntegerSample`.
   bool isIntegerEmpty() const;
 
   /// Returns a matrix where each row is a vector along which the polytope is
@@ -162,10 +163,10 @@ class FlatAffineConstraints {
   inline int64_t atEq(unsigned i, unsigned j) const { return equalities(i, j); }
   inline int64_t &atEq(unsigned i, unsigned j) { return equalities(i, j); }
 
+  /// Returns the value at the specified inequality row and column.
   inline int64_t atIneq(unsigned i, unsigned j) const {
     return inequalities(i, j);
   }
-
   inline int64_t &atIneq(unsigned i, unsigned j) { return inequalities(i, j); }
 
   /// Returns the number of columns in the constraint system.
@@ -208,8 +209,8 @@ class FlatAffineConstraints {
   /// being known and such a local variable appearing in any of the constraints.
   IntegerSet getAsIntegerSet(MLIRContext *context) const;
 
-  /// Computes the lower and upper bounds of the first 'num' dimensional
-  /// identifiers (starting at 'offset') as an affine map of the remaining
+  /// Computes the lower and upper bounds of the first `num` dimensional
+  /// identifiers (starting at `offset`) as an affine map of the remaining
   /// identifiers (dimensional and symbolic). This method is able to detect
   /// identifiers as floordiv's and mod's of affine expressions of other
   /// identifiers with respect to (positive) constants. Sets bound map to a
@@ -218,9 +219,9 @@ class FlatAffineConstraints {
                       SmallVectorImpl<AffineMap> *lbMaps,
                       SmallVectorImpl<AffineMap> *ubMaps);
 
-  /// Adds an inequality (>= 0) from the coefficients specified in inEq.
+  /// Adds an inequality (>= 0) from the coefficients specified in `inEq`.
   void addInequality(ArrayRef<int64_t> inEq);
-  /// Adds an equality from the coefficients specified in eq.
+  /// Adds an equality from the coefficients specified in `eq`.
   void addEquality(ArrayRef<int64_t> eq);
 
   /// Adds a constant lower bound constraint for the specified identifier.
@@ -229,8 +230,8 @@ class FlatAffineConstraints {
   void addConstantUpperBound(unsigned pos, int64_t ub);
 
   /// Adds a new local identifier as the floordiv of an affine function of other
-  /// identifiers, the coefficients of which are provided in 'dividend' and with
-  /// respect to a positive constant 'divisor'. Two constraints are added to the
+  /// identifiers, the coefficients of which are provided in `dividend` and with
+  /// respect to a positive constant `divisor`. Two constraints are added to the
   /// system to capture equivalence with the floordiv:
   /// q = dividend floordiv c    <=>   c*q <= dividend <= c*q + c - 1.
   void addLocalFloorDiv(ArrayRef<int64_t> dividend, int64_t divisor);
@@ -260,8 +261,8 @@ class FlatAffineConstraints {
   /// system. Returns failure if `other` is a semi-affine map.
   LogicalResult composeMatchingMap(AffineMap other);
 
-  /// Projects out (aka eliminates) 'num' identifiers starting at position
-  /// 'pos'. The resulting constraint system is the shadow along the dimensions
+  /// Projects out (aka eliminates) `num` identifiers starting at position
+  /// `pos`. The resulting constraint system is the shadow along the dimensions
   /// that still exist. This method may not always be integer exact.
   // TODO: deal with integer exactness when necessary - can return a value to
   // mark exactness for example.
@@ -274,8 +275,8 @@ class FlatAffineConstraints {
   void removeEquality(unsigned pos);
   void removeInequality(unsigned pos);
 
-  /// Sets the values.size() identifiers starting at pos to the specified values
-  /// and removes them.
+  /// Sets the `values.size()` identifiers starting at `po`s to the specified
+  /// values and removes them.
   void setAndEliminate(unsigned pos, ArrayRef<int64_t> values);
 
   /// Changes the partition between dimensions and symbols. Depending on the new
@@ -289,23 +290,27 @@ class FlatAffineConstraints {
   /// system.
   LogicalResult constantFoldId(unsigned pos);
 
-  /// This method calls constantFoldId for the specified range of identifiers,
-  /// 'num' identifiers starting at position 'pos'.
+  /// This method calls `constantFoldId` for the specified range of identifiers,
+  /// `num` identifiers starting at position `pos`.
   void constantFoldIdRange(unsigned pos, unsigned num);
 
   /// Updates the constraints to be the smallest bounding (enclosing) box that
-  /// contains the points of 'this' set and that of 'other', with the symbols
+  /// contains the points of `this` set and that of `other`, with the symbols
   /// being treated specially. For each of the dimensions, the min of the lower
   /// bounds (symbolic) and the max of the upper bounds (symbolic) is computed
-  /// to determine such a bounding box. `other' is expected to have the same
+  /// to determine such a bounding box. `other` is expected to have the same
   /// dimensional identifiers as this constraint system (in the same order).
   ///
-  /// Eg: if 'this' is {0 <= d0 <= 127}, 'other' is {16 <= d0 <= 192}, the
-  ///      output is {0 <= d0 <= 192}.
-  /// 2) 'this' = {s0 + 5 <= d0 <= s0 + 20}, 'other' is {s0 + 1 <= d0 <= s0 +
-  ///     9}, output = {s0 + 1 <= d0 <= s0 + 20}.
-  /// 3) 'this' = {0 <= d0 <= 5, 1 <= d1 <= 9}, 'other' = {2 <= d0 <= 6, 5 <= d1
-  ///     <= 15}, output = {0 <= d0 <= 6, 1 <= d1 <= 15}.
+  /// E.g.:
+  /// 1) this   = {0 <= d0 <= 127},
+  ///    other  = {16 <= d0 <= 192},
+  ///    output = {0 <= d0 <= 192}
+  /// 2) this   = {s0 + 5 <= d0 <= s0 + 20},
+  ///    other  = {s0 + 1 <= d0 <= s0 + 9},
+  ///    output = {s0 + 1 <= d0 <= s0 + 20}
+  /// 3) this   = {0 <= d0 <= 5, 1 <= d1 <= 9}
+  ///    other  = {2 <= d0 <= 6, 5 <= d1 <= 15},
+  ///    output = {0 <= d0 <= 6, 1 <= d1 <= 15}
   LogicalResult unionBoundingBox(const FlatAffineConstraints &other);
 
   unsigned getNumConstraints() const {
@@ -332,7 +337,7 @@ class FlatAffineConstraints {
   /// involving only the symbolic identifiers. `lb` and `ub` (along with the
   /// `boundFloorDivisor`) are set to represent the lower and upper bound
   /// associated with the constant 
diff erence: `lb`, `ub` have the coefficients,
-  /// and boundFloorDivisor, their divisor. `minLbPos` and `minUbPos` if
+  /// and `boundFloorDivisor`, their divisor. `minLbPos` and `minUbPos` if
   /// non-null are set to the position of the constant lower bound and upper
   /// bound respectively (to the same if they are from an equality). Ex: if the
   /// lower bound is [(s0 + s2 - 1) floordiv 32] for a system with three
@@ -375,7 +380,7 @@ class FlatAffineConstraints {
                                unsigned offset = 0, unsigned num = 0) const;
 
   /// Removes constraints that are independent of (i.e., do not have a
-  /// coefficient for) for identifiers in the range [pos, pos + num).
+  /// coefficient) identifiers in the range [pos, pos + num).
   void removeIndependentConstraints(unsigned pos, unsigned num);
 
   /// Returns true if the set can be trivially detected as being
@@ -390,8 +395,8 @@ class FlatAffineConstraints {
   /// constraints by their GCD and performs GCD tightening on inequalities.
   void removeTrivialRedundancy();
 
-  /// A more expensive check to detect redundant inequalities thatn
-  /// removeTrivialRedundancy.
+  /// A more expensive check than `removeTrivialRedundancy` to detect redundant
+  /// inequalities.
   void removeRedundantInequalities();
 
   /// Removes redundant constraints using Simplex. Although the algorithm can
@@ -415,8 +420,8 @@ class FlatAffineConstraints {
 
   /// Checks all rows of equality/inequality constraints for trivial
   /// contradictions (for example: 1 == 0, 0 >= 1), which may have surfaced
-  /// after elimination. Returns 'true' if an invalid constraint is found;
-  /// 'false'otherwise.
+  /// after elimination. Returns true if an invalid constraint is found;
+  /// false otherwise.
   bool hasInvalidConstraint() const;
 
   /// Returns the constant lower bound bound if isLower is true, and the upper
@@ -437,9 +442,9 @@ class FlatAffineConstraints {
   LogicalResult flattenAlignedMapAndMergeLocals(
       AffineMap map, std::vector<SmallVector<int64_t, 8>> *flattenedExprs);
 
-  /// Eliminates a single identifier at 'position' from equality and inequality
-  /// constraints. Returns 'success' if the identifier was eliminated, and
-  /// 'failure' otherwise.
+  /// Eliminates a single identifier at `position` from equality and inequality
+  /// constraints. Returns `success` if the identifier was eliminated, and
+  /// `failure` otherwise.
   inline LogicalResult gaussianEliminateId(unsigned position) {
     return success(gaussianEliminateIds(position, position + 1) == 1);
   }
@@ -449,10 +454,10 @@ class FlatAffineConstraints {
   /// Returns the number of variables eliminated.
   unsigned gaussianEliminateIds(unsigned posStart, unsigned posLimit);
 
-  /// Eliminates identifier at the specified position using Fourier-Motzkin
+  /// Eliminates the identifier at the specified position using Fourier-Motzkin
   /// variable elimination, but uses Gaussian elimination if there is an
   /// equality involving that identifier. If the result of the elimination is
-  /// integer exact, *isResultIntegerExact is set to true. If 'darkShadow' is
+  /// integer exact, `*isResultIntegerExact` is set to true. If `darkShadow` is
   /// set to true, a potential under approximation (subset) of the rational
   /// shadow / exact integer shadow is computed.
   // See implementation comments for more details.
@@ -514,28 +519,28 @@ class FlatAffineValueConstraints : public FlatAffineConstraints {
                              unsigned numReservedEqualities,
                              unsigned numReservedCols, unsigned numDims,
                              unsigned numSymbols, unsigned numLocals,
-                             ArrayRef<Optional<Value>> idArgs = {})
+                             ArrayRef<Optional<Value>> valArgs = {})
       : FlatAffineConstraints(numReservedInequalities, numReservedEqualities,
                               numReservedCols, numDims, numSymbols, numLocals) {
     assert(numReservedCols >= numIds + 1);
-    assert(idArgs.empty() || idArgs.size() == numIds);
-    ids.reserve(numReservedCols);
-    if (idArgs.empty())
-      ids.resize(numIds, None);
+    assert(valArgs.empty() || valArgs.size() == numIds);
+    values.reserve(numReservedCols);
+    if (valArgs.empty())
+      values.resize(numIds, None);
     else
-      ids.append(idArgs.begin(), idArgs.end());
+      values.append(valArgs.begin(), valArgs.end());
   }
 
   /// Constructs a constraint system with the specified number of
   /// dimensions and symbols.
   FlatAffineValueConstraints(unsigned numDims = 0, unsigned numSymbols = 0,
                              unsigned numLocals = 0,
-                             ArrayRef<Optional<Value>> idArgs = {})
+                             ArrayRef<Optional<Value>> valArgs = {})
       : FlatAffineValueConstraints(/*numReservedInequalities=*/0,
                                    /*numReservedEqualities=*/0,
                                    /*numReservedCols=*/numDims + numSymbols +
                                        numLocals + 1,
-                                   numDims, numSymbols, numLocals, idArgs) {}
+                                   numDims, numSymbols, numLocals, valArgs) {}
 
   /// Create a flat affine constraint system from an AffineValueMap or a list of
   /// these. The constructed system will only include equalities.
@@ -562,9 +567,9 @@ class FlatAffineValueConstraints : public FlatAffineConstraints {
              unsigned numLocals = 0) override;
   void reset(unsigned numReservedInequalities, unsigned numReservedEqualities,
              unsigned numReservedCols, unsigned numDims, unsigned numSymbols,
-             unsigned numLocals, ArrayRef<Value> idArgs);
+             unsigned numLocals, ArrayRef<Value> valArgs);
   void reset(unsigned numDims, unsigned numSymbols, unsigned numLocals,
-             ArrayRef<Value> idArgs);
+             ArrayRef<Value> valArgs);
   using FlatAffineConstraints::reset;
 
   /// Clones this object.
@@ -572,7 +577,7 @@ class FlatAffineValueConstraints : public FlatAffineConstraints {
 
   /// Adds constraints (lower and upper bounds) for the specified 'affine.for'
   /// operation's Value using IR information stored in its bound maps. The
-  /// right identifier is first looked up using forOp's Value. Asserts if the
+  /// right identifier is first looked up using `forOp`'s Value. Asserts if the
   /// Value corresponding to the 'affine.for' operation isn't found in the
   /// constraint system. Returns failure for the yet unimplemented/unsupported
   /// cases.  Any new identifiers that are found in the bound operands of the
@@ -583,9 +588,9 @@ class FlatAffineValueConstraints : public FlatAffineConstraints {
   LogicalResult addAffineForOpDomain(AffineForOp forOp);
 
   /// Adds constraints (lower and upper bounds) for each loop in the loop nest
-  /// described by the bound maps 'lbMaps' and 'ubMaps' of a computation slice.
-  /// Every pair ('lbMaps[i]', 'ubMaps[i]') describes the bounds of a loop in
-  /// the nest, sorted outer-to-inner. 'operands' contains the bound operands
+  /// described by the bound maps `lbMaps` and `ubMaps` of a computation slice.
+  /// Every pair (`lbMaps[i]`, `ubMaps[i]`) describes the bounds of a loop in
+  /// the nest, sorted outer-to-inner. `operands` contains the bound operands
   /// for a single bound map. All the bound maps will use the same bound
   /// operands. Note that some loops described by a computation slice might not
   /// exist yet in the IR so the Value attached to those dimension identifiers
@@ -624,52 +629,52 @@ class FlatAffineValueConstraints : public FlatAffineConstraints {
                                AffineValueMap &vmap,
                                MLIRContext *context) const;
 
-  /// Adds slice lower bounds represented by lower bounds in 'lbMaps' and upper
-  /// bounds in 'ubMaps' to each identifier in the constraint system which has
-  /// a value in 'values'. Note that both lower/upper bounds share the same
-  /// operand list 'operands'.
-  /// This function assumes 'values.size' == 'lbMaps.size' == 'ubMaps.size'.
-  /// Note that both lower/upper bounds use operands from 'operands'.
+  /// Adds slice lower bounds represented by lower bounds in `lbMaps` and upper
+  /// bounds in `ubMaps` to each identifier in the constraint system which has
+  /// a value in `values`. Note that both lower/upper bounds share the same
+  /// operand list `operands`.
+  /// This function assumes `values.size` == `lbMaps.size` == `ubMaps.size`.
+  /// Note that both lower/upper bounds use operands from `operands`.
   LogicalResult addSliceBounds(ArrayRef<Value> values,
                                ArrayRef<AffineMap> lbMaps,
                                ArrayRef<AffineMap> ubMaps,
                                ArrayRef<Value> operands);
 
-  /// Sets the identifier corresponding to the specified Value id to a
-  /// constant. Asserts if the 'id' is not found.
-  void setIdToConstant(Value id, int64_t val);
+  /// Sets the identifier corresponding to the specified Value `value` to a
+  /// constant. Asserts if the `value` is not found.
+  void setIdToConstant(Value value, int64_t val);
   using FlatAffineConstraints::setIdToConstant;
 
   /// Looks up the position of the identifier with the specified Value. Returns
-  /// true if found (false otherwise). `pos' is set to the (column) position of
+  /// true if found (false otherwise). `pos` is set to the (column) position of
   /// the identifier.
-  bool findId(Value id, unsigned *pos) const;
+  bool findId(Value val, unsigned *pos) const;
 
   /// Returns true if an identifier with the specified Value exists, false
   /// otherwise.
-  bool containsId(Value id) const;
+  bool containsId(Value val) const;
 
   /// Swap the posA^th identifier with the posB^th identifier.
   void swapId(unsigned posA, unsigned posB) override;
 
   /// Add identifiers of the specified kind - specified positions are relative
   /// to the kind of identifier. The coefficient column corresponding to the
-  /// added identifier is initialized to zero. 'id' is the Value corresponding
+  /// added identifier is initialized to zero. `val` is the Value corresponding
   /// to the identifier that can optionally be provided.
-  void addDimId(unsigned pos, Value id);
+  void addDimId(unsigned pos, Value val);
   using FlatAffineConstraints::addDimId;
-  void addSymbolId(unsigned pos, Value id);
+  void addSymbolId(unsigned pos, Value val);
   using FlatAffineConstraints::addSymbolId;
   unsigned addId(IdKind kind, unsigned pos) override;
-  unsigned addId(IdKind kind, unsigned pos, Value id);
+  unsigned addId(IdKind kind, unsigned pos, Value val);
 
   /// Add the specified values as a dim or symbol id depending on its nature, if
-  /// it already doesn't exist in the system. `id' has to be either a terminal
+  /// it already doesn't exist in the system. `val` has to be either a terminal
   /// symbol or a loop IV, i.e., it cannot be the result affine.apply of any
   /// symbols or loop IVs. The identifier is added to the end of the existing
   /// dims or symbols. Additional information on the identifier is extracted
   /// from the IR and added to the constraint system.
-  void addInductionVarOrTerminalSymbol(Value id);
+  void addInductionVarOrTerminalSymbol(Value val);
 
   /// Align `map` with this constraint system based on `operands`. Each operand
   /// must already have a corresponding dim/symbol in this constraint system.
@@ -688,104 +693,100 @@ class FlatAffineValueConstraints : public FlatAffineConstraints {
   LogicalResult composeMap(const AffineValueMap *vMap);
 
   /// Projects out the identifier that is associate with Value.
-  void projectOut(Value id);
+  void projectOut(Value val);
   using FlatAffineConstraints::projectOut;
 
   /// Changes all symbol identifiers which are loop IVs to dim identifiers.
   void convertLoopIVSymbolsToDims();
 
   /// Updates the constraints to be the smallest bounding (enclosing) box that
-  /// contains the points of 'this' set and that of 'other', with the symbols
+  /// contains the points of `this` set and that of `other`, with the symbols
   /// being treated specially. For each of the dimensions, the min of the lower
   /// bounds (symbolic) and the max of the upper bounds (symbolic) is computed
-  /// to determine such a bounding box. `other' is expected to have the same
+  /// to determine such a bounding box. `other` is expected to have the same
   /// dimensional identifiers as this constraint system (in the same order).
   ///
-  /// Eg: if 'this' is {0 <= d0 <= 127}, 'other' is {16 <= d0 <= 192}, the
-  ///      output is {0 <= d0 <= 192}.
-  /// 2) 'this' = {s0 + 5 <= d0 <= s0 + 20}, 'other' is {s0 + 1 <= d0 <= s0 +
-  ///     9}, output = {s0 + 1 <= d0 <= s0 + 20}.
-  /// 3) 'this' = {0 <= d0 <= 5, 1 <= d1 <= 9}, 'other' = {2 <= d0 <= 6, 5 <= d1
-  ///     <= 15}, output = {0 <= d0 <= 6, 1 <= d1 <= 15}.
+  /// E.g.:
+  /// 1) this   = {0 <= d0 <= 127},
+  ///    other  = {16 <= d0 <= 192},
+  ///    output = {0 <= d0 <= 192}
+  /// 2) this   = {s0 + 5 <= d0 <= s0 + 20},
+  ///    other  = {s0 + 1 <= d0 <= s0 + 9},
+  ///    output = {s0 + 1 <= d0 <= s0 + 20}
+  /// 3) this   = {0 <= d0 <= 5, 1 <= d1 <= 9}
+  ///    other  = {2 <= d0 <= 6, 5 <= d1 <= 15},
+  ///    output = {0 <= d0 <= 6, 1 <= d1 <= 15}
   LogicalResult unionBoundingBox(const FlatAffineValueConstraints &other);
   using FlatAffineConstraints::unionBoundingBox;
 
-  /// Merge and align the identifiers of 'this' and 'other' starting at
-  /// 'offset', so that both constraint systems get the union of the contained
+  /// Merge and align the identifiers of `this` and `other` starting at
+  /// `offset`, so that both constraint systems get the union of the contained
   /// identifiers that is dimension-wise and symbol-wise unique; both
   /// constraint systems are updated so that they have the union of all
-  /// identifiers, with this's original identifiers appearing first followed by
-  /// any of other's identifiers that didn't appear in 'this'. Local
+  /// identifiers, with `this`'s original identifiers appearing first followed
+  /// by any of `other`'s identifiers that didn't appear in `this`. Local
   /// identifiers of each system are by design separate/local and are placed
-  /// one after other (this's followed by other's).
-  //  Eg: Input: 'this'  has ((%i %j) [%M %N])
-  //             'other' has (%k, %j) [%P, %N, %M])
-  //      Output: both 'this', 'other' have (%i, %j, %k) [%M, %N, %P]
+  /// one after other (`this`'s followed by `other`'s).
+  //  Eg: Input: `this`  has (%i %j) [%M %N]
+  //             `other` has (%k, %j) [%P, %N, %M]
+  //      Output: both `this`, `other` have (%i, %j, %k) [%M, %N, %P]
   //
   void mergeAndAlignIdsWithOther(unsigned offset,
                                  FlatAffineValueConstraints *other);
 
-  /// Returns 'true' if this constraint system and 'other' are in the same
+  /// Returns true if this constraint system and `other` are in the same
   /// space, i.e., if they are associated with the same set of identifiers,
-  /// appearing in the same order. Returns 'false' otherwise.
+  /// appearing in the same order. Returns false otherwise.
   bool areIdsAlignedWithOther(const FlatAffineValueConstraints &other);
 
   /// Replaces the contents of this FlatAffineValueConstraints with `other`.
   void clearAndCopyFrom(const FlatAffineConstraints &other) override;
 
-  inline ArrayRef<Optional<Value>> getIds() const {
-    return {ids.data(), ids.size()};
-  }
-  inline MutableArrayRef<Optional<Value>> getIds() {
-    return {ids.data(), ids.size()};
-  }
-
-  /// Returns the optional Value corresponding to the pos^th identifier.
-  inline Optional<Value> getId(unsigned pos) const { return ids[pos]; }
-  inline Optional<Value> &getId(unsigned pos) { return ids[pos]; }
-
   /// Returns the Value associated with the pos^th identifier. Asserts if
   /// no Value identifier was associated.
-  inline Value getIdValue(unsigned pos) const {
-    assert(hasIdValue(pos) && "identifier's Value not set");
-    return ids[pos].getValue();
+  inline Value getValue(unsigned pos) const {
+    assert(hasValue(pos) && "identifier's Value not set");
+    return values[pos].getValue();
   }
 
   /// Returns true if the pos^th identifier has an associated Value.
-  inline bool hasIdValue(unsigned pos) const { return ids[pos].hasValue(); }
+  inline bool hasValue(unsigned pos) const { return values[pos].hasValue(); }
 
   /// Returns true if at least one identifier has an associated Value.
-  bool hasIdValues() const;
+  bool hasValues() const;
 
   /// Returns the Values associated with identifiers in range [start, end).
   /// Asserts if no Value was associated with one of these identifiers.
-  void getIdValues(unsigned start, unsigned end,
-                   SmallVectorImpl<Value> *values) const {
+  inline void getValues(unsigned start, unsigned end,
+                        SmallVectorImpl<Value> *values) const {
     assert((start < numIds || start == end) && "invalid start position");
     assert(end <= numIds && "invalid end position");
     values->clear();
     values->reserve(end - start);
-    for (unsigned i = start; i < end; i++) {
-      values->push_back(getIdValue(i));
-    }
+    for (unsigned i = start; i < end; i++)
+      values->push_back(getValue(i));
+  }
+  inline void getAllValues(SmallVectorImpl<Value> *values) const {
+    getValues(0, numIds, values);
   }
-  inline void getAllIdValues(SmallVectorImpl<Value> *values) const {
-    getIdValues(0, numIds, values);
+
+  inline ArrayRef<Optional<Value>> getMaybeValues() const {
+    return {values.data(), values.size()};
   }
 
-  /// Sets Value associated with the pos^th identifier.
-  inline void setIdValue(unsigned pos, Value val) {
+  /// Sets the Value associated with the pos^th identifier.
+  inline void setValue(unsigned pos, Value val) {
     assert(pos < numIds && "invalid id position");
-    ids[pos] = val;
+    values[pos] = val;
   }
 
-  /// Sets Values associated with identifiers in the range [start, end).
-  void setIdValues(unsigned start, unsigned end, ArrayRef<Value> values) {
+  /// Sets the Values associated with the identifiers in the range [start, end).
+  void setValues(unsigned start, unsigned end, ArrayRef<Value> values) {
     assert((start < numIds || end == start) && "invalid start position");
     assert(end <= numIds && "invalid end position");
     assert(values.size() == end - start);
     for (unsigned i = start; i < end; ++i)
-      ids[i] = values[i - start];
+      setValue(i, values[i - start]);
   }
 
 protected:
@@ -799,10 +800,10 @@ class FlatAffineValueConstraints : public FlatAffineConstraints {
   /// arrays as needed.
   void removeIdRange(unsigned idStart, unsigned idLimit) override;
 
-  /// Eliminates identifier at the specified position using Fourier-Motzkin
+  /// Eliminates the identifier at the specified position using Fourier-Motzkin
   /// variable elimination, but uses Gaussian elimination if there is an
   /// equality involving that identifier. If the result of the elimination is
-  /// integer exact, *isResultIntegerExact is set to true. If 'darkShadow' is
+  /// integer exact, `*isResultIntegerExact` is set to true. If `darkShadow` is
   /// set to true, a potential under approximation (subset) of the rational
   /// shadow / exact integer shadow is computed.
   // See implementation comments for more details.
@@ -811,9 +812,9 @@ class FlatAffineValueConstraints : public FlatAffineConstraints {
 
   /// Values corresponding to the (column) identifiers of this constraint
   /// system appearing in the order the identifiers correspond to columns.
-  /// Temporary ones or those that aren't associated to any Value are set to
+  /// Temporary ones or those that aren't associated with any Value are set to
   /// None.
-  SmallVector<Optional<Value>, 8> ids;
+  SmallVector<Optional<Value>, 8> values;
 };
 
 /// Flattens 'expr' into 'flattenedExpr', which contains the coefficients of the

diff  --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp
index 293bcf8c0dd94..e3feb780bdf46 100644
--- a/mlir/lib/Analysis/AffineAnalysis.cpp
+++ b/mlir/lib/Analysis/AffineAnalysis.cpp
@@ -413,12 +413,12 @@ static void buildDimAndSymbolPositionMaps(
   // the collected values into dim and symbol parts.
   SmallVector<Value, 4> srcDimValues, dstDimValues, srcSymbolValues,
       dstSymbolValues;
-  srcDomain.getIdValues(0, srcDomain.getNumDimIds(), &srcDimValues);
-  dstDomain.getIdValues(0, dstDomain.getNumDimIds(), &dstDimValues);
-  srcDomain.getIdValues(srcDomain.getNumDimIds(),
-                        srcDomain.getNumDimAndSymbolIds(), &srcSymbolValues);
-  dstDomain.getIdValues(dstDomain.getNumDimIds(),
-                        dstDomain.getNumDimAndSymbolIds(), &dstSymbolValues);
+  srcDomain.getValues(0, srcDomain.getNumDimIds(), &srcDimValues);
+  dstDomain.getValues(0, dstDomain.getNumDimIds(), &dstDimValues);
+  srcDomain.getValues(srcDomain.getNumDimIds(),
+                      srcDomain.getNumDimAndSymbolIds(), &srcSymbolValues);
+  dstDomain.getValues(dstDomain.getNumDimIds(),
+                      dstDomain.getNumDimAndSymbolIds(), &dstSymbolValues);
 
   // Update value position map with dim values from src iteration domain.
   updateValuePosMap(srcDimValues, /*isSrc=*/true, /*isDim=*/TRUE);
@@ -464,11 +464,11 @@ initDependenceConstraints(const FlatAffineValueConstraints &srcDomain,
 
   // Set values corresponding to dependence constraint identifiers.
   SmallVector<Value, 4> srcLoopIVs, dstLoopIVs;
-  srcDomain.getIdValues(0, srcDomain.getNumDimIds(), &srcLoopIVs);
-  dstDomain.getIdValues(0, dstDomain.getNumDimIds(), &dstLoopIVs);
+  srcDomain.getValues(0, srcDomain.getNumDimIds(), &srcLoopIVs);
+  dstDomain.getValues(0, dstDomain.getNumDimIds(), &dstLoopIVs);
 
-  dependenceConstraints->setIdValues(0, srcLoopIVs.size(), srcLoopIVs);
-  dependenceConstraints->setIdValues(
+  dependenceConstraints->setValues(0, srcLoopIVs.size(), srcLoopIVs);
+  dependenceConstraints->setValues(
       srcLoopIVs.size(), srcLoopIVs.size() + dstLoopIVs.size(), dstLoopIVs);
 
   // Set values for the symbolic identifier dimensions. `isSymbolDetermined`
@@ -481,7 +481,7 @@ initDependenceConstraints(const FlatAffineValueConstraints &srcDomain,
     for (auto value : values) {
       if (isSymbolDetermined || !isForInductionVar(value)) {
         assert(isValidSymbol(value) && "expected symbol");
-        dependenceConstraints->setIdValue(valuePosMap.getSymPos(value), value);
+        dependenceConstraints->setValue(valuePosMap.getSymPos(value), value);
       }
     }
   };
@@ -492,10 +492,10 @@ initDependenceConstraints(const FlatAffineValueConstraints &srcDomain,
   setSymbolIds(dstAccessMap.getOperands(), /*isSymbolDetermined=*/false);
 
   SmallVector<Value, 8> srcSymbolValues, dstSymbolValues;
-  srcDomain.getIdValues(srcDomain.getNumDimIds(),
-                        srcDomain.getNumDimAndSymbolIds(), &srcSymbolValues);
-  dstDomain.getIdValues(dstDomain.getNumDimIds(),
-                        dstDomain.getNumDimAndSymbolIds(), &dstSymbolValues);
+  srcDomain.getValues(srcDomain.getNumDimIds(),
+                      srcDomain.getNumDimAndSymbolIds(), &srcSymbolValues);
+  dstDomain.getValues(dstDomain.getNumDimIds(),
+                      dstDomain.getNumDimAndSymbolIds(), &dstSymbolValues);
   // Since we only take symbol Values out of `srcDomain` and `dstDomain`,
   // `isSymbolDetermined` is kept to its default value: true.
   setSymbolIds(srcSymbolValues);
@@ -503,7 +503,7 @@ initDependenceConstraints(const FlatAffineValueConstraints &srcDomain,
 
   for (unsigned i = 0, e = dependenceConstraints->getNumDimAndSymbolIds();
        i < e; i++)
-    assert(dependenceConstraints->getIds()[i].hasValue());
+    assert(dependenceConstraints->hasValue(i));
 }
 
 // Adds iteration domain constraints from 'srcDomain' and 'dstDomain' into
@@ -527,8 +527,8 @@ static void addDomainConstraints(const FlatAffineValueConstraints &srcDomain,
       return isEq ? domain.atEq(i, j) : domain.atIneq(i, j);
     };
     auto map = [&](unsigned i) -> int64_t {
-      return isSrc ? valuePosMap.getSrcDimOrSymPos(domain.getIdValue(i))
-                   : valuePosMap.getDstDimOrSymPos(domain.getIdValue(i));
+      return isSrc ? valuePosMap.getSrcDimOrSymPos(domain.getValue(i))
+                   : valuePosMap.getDstDimOrSymPos(domain.getValue(i));
     };
 
     for (unsigned i = 0; i < numCsts; ++i) {
@@ -727,12 +727,12 @@ getNumCommonLoops(const FlatAffineValueConstraints &srcDomain,
       std::min(srcDomain.getNumDimIds(), dstDomain.getNumDimIds());
   unsigned numCommonLoops = 0;
   for (unsigned i = 0; i < minNumLoops; ++i) {
-    if (!isForInductionVar(srcDomain.getIdValue(i)) ||
-        !isForInductionVar(dstDomain.getIdValue(i)) ||
-        srcDomain.getIdValue(i) != dstDomain.getIdValue(i))
+    if (!isForInductionVar(srcDomain.getValue(i)) ||
+        !isForInductionVar(dstDomain.getValue(i)) ||
+        srcDomain.getValue(i) != dstDomain.getValue(i))
       break;
     if (commonLoops != nullptr)
-      commonLoops->push_back(getForInductionVarOwner(srcDomain.getIdValue(i)));
+      commonLoops->push_back(getForInductionVarOwner(srcDomain.getValue(i)));
     ++numCommonLoops;
   }
   if (commonLoops != nullptr)
@@ -768,7 +768,7 @@ static Block *getCommonBlock(const MemRefAccess &srcAccess,
     }
     return block;
   }
-  Value commonForIV = srcDomain.getIdValue(numCommonLoops - 1);
+  Value commonForIV = srcDomain.getValue(numCommonLoops - 1);
   AffineForOp forOp = getForInductionVarOwner(commonForIV);
   assert(forOp && "commonForValue was not an induction variable");
 

diff  --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp
index d36893bca61c6..bb636299358e3 100644
--- a/mlir/lib/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Analysis/AffineStructures.cpp
@@ -188,7 +188,7 @@ FlatAffineConstraints::FlatAffineConstraints(IntegerSet set)
 // Construct from an IntegerSet.
 FlatAffineValueConstraints::FlatAffineValueConstraints(IntegerSet set)
     : FlatAffineConstraints(set) {
-  ids.resize(numIds, None);
+  values.resize(numIds, None);
 }
 
 void FlatAffineConstraints::reset(unsigned numReservedInequalities,
@@ -210,22 +210,22 @@ void FlatAffineValueConstraints::reset(unsigned numReservedInequalities,
                                        unsigned newNumSymbols,
                                        unsigned newNumLocals) {
   reset(numReservedInequalities, numReservedEqualities, newNumReservedCols,
-        newNumDims, newNumSymbols, newNumLocals, /*idArgs=*/{});
+        newNumDims, newNumSymbols, newNumLocals, /*valArgs=*/{});
 }
 
 void FlatAffineValueConstraints::reset(
     unsigned numReservedInequalities, unsigned numReservedEqualities,
     unsigned newNumReservedCols, unsigned newNumDims, unsigned newNumSymbols,
-    unsigned newNumLocals, ArrayRef<Value> idArgs) {
+    unsigned newNumLocals, ArrayRef<Value> valArgs) {
   assert(newNumReservedCols >= newNumDims + newNumSymbols + newNumLocals + 1 &&
          "minimum 1 column");
-  SmallVector<Optional<Value>, 8> newIds;
-  if (!idArgs.empty())
-    newIds.assign(idArgs.begin(), idArgs.end());
+  SmallVector<Optional<Value>, 8> newVals;
+  if (!valArgs.empty())
+    newVals.assign(valArgs.begin(), valArgs.end());
 
   *this = FlatAffineValueConstraints(
       numReservedInequalities, numReservedEqualities, newNumReservedCols,
-      newNumDims, newNumSymbols, newNumLocals, newIds);
+      newNumDims, newNumSymbols, newNumLocals, newVals);
 }
 
 void FlatAffineConstraints::reset(unsigned newNumDims, unsigned newNumSymbols,
@@ -237,9 +237,9 @@ void FlatAffineConstraints::reset(unsigned newNumDims, unsigned newNumSymbols,
 void FlatAffineValueConstraints::reset(unsigned newNumDims,
                                        unsigned newNumSymbols,
                                        unsigned newNumLocals,
-                                       ArrayRef<Value> idArgs) {
+                                       ArrayRef<Value> valArgs) {
   reset(0, 0, newNumDims + newNumSymbols + newNumLocals + 1, newNumDims,
-        newNumSymbols, newNumLocals, idArgs);
+        newNumSymbols, newNumLocals, valArgs);
 }
 
 void FlatAffineConstraints::append(const FlatAffineConstraints &other) {
@@ -267,16 +267,16 @@ void FlatAffineConstraints::addDimId(unsigned pos) {
   addId(IdKind::Dimension, pos);
 }
 
-void FlatAffineValueConstraints::addDimId(unsigned pos, Value id) {
-  addId(IdKind::Dimension, pos, id);
+void FlatAffineValueConstraints::addDimId(unsigned pos, Value val) {
+  addId(IdKind::Dimension, pos, val);
 }
 
 void FlatAffineConstraints::addSymbolId(unsigned pos) {
   addId(IdKind::Symbol, pos);
 }
 
-void FlatAffineValueConstraints::addSymbolId(unsigned pos, Value id) {
-  addId(IdKind::Symbol, pos, id);
+void FlatAffineValueConstraints::addSymbolId(unsigned pos, Value val) {
+  addId(IdKind::Symbol, pos, val);
 }
 
 unsigned FlatAffineConstraints::addId(IdKind kind, unsigned pos) {
@@ -306,26 +306,27 @@ unsigned FlatAffineConstraints::addId(IdKind kind, unsigned pos) {
 }
 
 unsigned FlatAffineValueConstraints::addId(IdKind kind, unsigned pos) {
-  return addId(kind, pos, /*id=*/{});
+  return addId(kind, pos, /*val=*/{});
 }
 
 unsigned FlatAffineValueConstraints::addId(IdKind kind, unsigned pos,
-                                           Value id) {
+                                           Value val) {
   unsigned absolutePos = FlatAffineConstraints::addId(kind, pos);
 
   // If an 'id' is provided, insert it; otherwise use None.
-  if (id)
-    ids.insert(ids.begin() + absolutePos, id);
+  if (val)
+    values.insert(values.begin() + absolutePos, val);
   else
-    ids.insert(ids.begin() + absolutePos, None);
-  assert(ids.size() == getNumIds());
+    values.insert(values.begin() + absolutePos, None);
+  assert(values.size() == getNumIds());
 
   return absolutePos;
 }
 
-bool FlatAffineValueConstraints::hasIdValues() const {
-  return llvm::find_if(ids, [](Optional<Value> id) { return id.hasValue(); }) !=
-         ids.end();
+bool FlatAffineValueConstraints::hasValues() const {
+  return llvm::find_if(values, [](Optional<Value> id) {
+           return id.hasValue();
+         }) != values.end();
 }
 
 /// Checks if two constraint systems are in the same space, i.e., if they are
@@ -334,7 +335,8 @@ static bool areIdsAligned(const FlatAffineValueConstraints &a,
                           const FlatAffineValueConstraints &b) {
   return a.getNumDimIds() == b.getNumDimIds() &&
          a.getNumSymbolIds() == b.getNumSymbolIds() &&
-         a.getNumIds() == b.getNumIds() && a.getIds().equals(b.getIds());
+         a.getNumIds() == b.getNumIds() &&
+         a.getMaybeValues().equals(b.getMaybeValues());
 }
 
 /// Calls areIdsAligned to check if two constraint systems have the same set
@@ -344,12 +346,12 @@ bool FlatAffineValueConstraints::areIdsAlignedWithOther(
   return areIdsAligned(*this, other);
 }
 
-/// Checks if the SSA values associated with `cst''s identifiers are unique.
+/// Checks if the SSA values associated with `cst`'s identifiers are unique.
 static bool LLVM_ATTRIBUTE_UNUSED
 areIdsUnique(const FlatAffineValueConstraints &cst) {
   SmallPtrSet<Value, 8> uniqueIds;
-  for (auto id : cst.getIds()) {
-    if (id.hasValue() && !uniqueIds.insert(id.getValue()).second)
+  for (auto val : cst.getMaybeValues()) {
+    if (val.hasValue() && !uniqueIds.insert(val.getValue()).second)
       return false;
   }
   return true;
@@ -368,15 +370,15 @@ static void mergeAndAlignIds(unsigned offset, FlatAffineValueConstraints *a,
                              FlatAffineValueConstraints *b) {
   assert(offset <= a->getNumDimIds() && offset <= b->getNumDimIds());
   // A merge/align isn't meaningful if a cst's ids aren't distinct.
-  assert(areIdsUnique(*a) && "A's id values aren't unique");
-  assert(areIdsUnique(*b) && "B's id values aren't unique");
+  assert(areIdsUnique(*a) && "A's values aren't unique");
+  assert(areIdsUnique(*b) && "B's values aren't unique");
 
-  assert(std::all_of(a->getIds().begin() + offset,
-                     a->getIds().begin() + a->getNumDimAndSymbolIds(),
+  assert(std::all_of(a->getMaybeValues().begin() + offset,
+                     a->getMaybeValues().begin() + a->getNumDimAndSymbolIds(),
                      [](Optional<Value> id) { return id.hasValue(); }));
 
-  assert(std::all_of(b->getIds().begin() + offset,
-                     b->getIds().begin() + b->getNumDimAndSymbolIds(),
+  assert(std::all_of(b->getMaybeValues().begin() + offset,
+                     b->getMaybeValues().begin() + b->getNumDimAndSymbolIds(),
                      [](Optional<Value> id) { return id.hasValue(); }));
 
   // Place local id's of A after local id's of B.
@@ -389,8 +391,8 @@ static void mergeAndAlignIds(unsigned offset, FlatAffineValueConstraints *a,
   }
 
   SmallVector<Value, 4> aDimValues, aSymValues;
-  a->getIdValues(offset, a->getNumDimIds(), &aDimValues);
-  a->getIdValues(a->getNumDimIds(), a->getNumDimAndSymbolIds(), &aSymValues);
+  a->getValues(offset, a->getNumDimIds(), &aDimValues);
+  a->getValues(a->getNumDimIds(), a->getNumDimAndSymbolIds(), &aSymValues);
   {
     // Merge dims from A into B.
     unsigned d = offset;
@@ -403,7 +405,7 @@ static void mergeAndAlignIds(unsigned offset, FlatAffineValueConstraints *a,
         b->swapId(d, loc);
       } else {
         b->addDimId(d);
-        b->setIdValue(d, aDimValue);
+        b->setValue(d, aDimValue);
       }
       d++;
     }
@@ -411,7 +413,7 @@ static void mergeAndAlignIds(unsigned offset, FlatAffineValueConstraints *a,
     // Dimensions that are in B, but not in A, are added at the end.
     for (unsigned t = a->getNumDimIds(), e = b->getNumDimIds(); t < e; t++) {
       a->addDimId(a->getNumDimIds());
-      a->setIdValue(a->getNumDimIds() - 1, b->getIdValue(t));
+      a->setValue(a->getNumDimIds() - 1, b->getValue(t));
     }
   }
   {
@@ -425,7 +427,7 @@ static void mergeAndAlignIds(unsigned offset, FlatAffineValueConstraints *a,
         b->swapId(s, loc);
       } else {
         b->addSymbolId(s - b->getNumDimIds());
-        b->setIdValue(s, aSymValue);
+        b->setValue(s, aSymValue);
       }
       s++;
     }
@@ -434,7 +436,7 @@ static void mergeAndAlignIds(unsigned offset, FlatAffineValueConstraints *a,
                   e = b->getNumDimAndSymbolIds();
          t < e; t++) {
       a->addSymbolId(a->getNumSymbolIds());
-      a->setIdValue(a->getNumDimAndSymbolIds() - 1, b->getIdValue(t));
+      a->setValue(a->getNumDimAndSymbolIds() - 1, b->getValue(t));
     }
   }
   assert(areIdsAligned(*a, *b) && "IDs expected to be aligned");
@@ -520,8 +522,8 @@ void FlatAffineValueConstraints::convertLoopIVSymbolsToDims() {
   // Gather all symbols which are loop IVs.
   SmallVector<Value, 4> loopIVs;
   for (unsigned i = getNumDimIds(), e = getNumDimAndSymbolIds(); i < e; i++) {
-    if (ids[i].hasValue() && getForInductionVarOwner(ids[i].getValue()))
-      loopIVs.push_back(ids[i].getValue());
+    if (hasValue(i) && getForInductionVarOwner(getValue(i)))
+      loopIVs.push_back(getValue(i));
   }
   // Turn each symbol in 'loopIVs' into a dim identifier.
   for (auto iv : loopIVs) {
@@ -529,26 +531,26 @@ void FlatAffineValueConstraints::convertLoopIVSymbolsToDims() {
   }
 }
 
-void FlatAffineValueConstraints::addInductionVarOrTerminalSymbol(Value id) {
-  if (containsId(id))
+void FlatAffineValueConstraints::addInductionVarOrTerminalSymbol(Value val) {
+  if (containsId(val))
     return;
 
   // Caller is expected to fully compose map/operands if necessary.
-  assert((isTopLevelValue(id) || isForInductionVar(id)) &&
+  assert((isTopLevelValue(val) || isForInductionVar(val)) &&
          "non-terminal symbol / loop IV expected");
   // Outer loop IVs could be used in forOp's bounds.
-  if (auto loop = getForInductionVarOwner(id)) {
-    addDimId(getNumDimIds(), id);
+  if (auto loop = getForInductionVarOwner(val)) {
+    addDimId(getNumDimIds(), val);
     if (failed(this->addAffineForOpDomain(loop)))
       LLVM_DEBUG(
           loop.emitWarning("failed to add domain info to constraint system"));
     return;
   }
   // Add top level symbol.
-  addSymbolId(getNumSymbolIds(), id);
+  addSymbolId(getNumSymbolIds(), val);
   // Check if the symbol is a constant.
-  if (auto constOp = id.getDefiningOp<ConstantIndexOp>())
-    setIdToConstant(id, constOp.getValue());
+  if (auto constOp = val.getDefiningOp<ConstantIndexOp>())
+    setIdToConstant(val, constOp.getValue());
 }
 
 LogicalResult
@@ -605,17 +607,6 @@ FlatAffineValueConstraints::addAffineForOpDomain(AffineForOp forOp) {
                               /*eq=*/false, /*lower=*/false);
 }
 
-/// Adds constraints (lower and upper bounds) for each loop in the loop nest
-/// described by the bound maps 'lbMaps' and 'ubMaps' of a computation slice.
-/// Every pair ('lbMaps[i]', 'ubMaps[i]') describes the bounds of a loop in
-/// the nest, sorted outer-to-inner. 'operands' contains the bound operands
-/// for a single bound map. All the bound maps will use the same bound
-/// operands. Note that some loops described by a computation slice might not
-/// exist yet in the IR so the Value attached to those dimension identifiers
-/// might be empty. For that reason, this method doesn't perform Value
-/// look-ups to retrieve the dimension identifier positions. Instead, it
-/// assumes the position of the dim identifiers in the constraint system is
-/// the same as the position of the loop in the loop nest.
 LogicalResult
 FlatAffineValueConstraints::addDomainFromSliceMaps(ArrayRef<AffineMap> lbMaps,
                                                    ArrayRef<AffineMap> ubMaps,
@@ -675,7 +666,7 @@ void FlatAffineValueConstraints::addAffineIfOpDomain(AffineIfOp ifOp) {
 
   // Bind ids in the constraints to ifOp operands.
   SmallVector<Value, 4> operands = ifOp.getOperands();
-  cst.setIdValues(0, cst.getNumDimAndSymbolIds(), operands);
+  cst.setValues(0, cst.getNumDimAndSymbolIds(), operands);
 
   // Merge the constraints from ifOp to the current domain. We need first merge
   // and align the IDs from both constraints, and then append the constraints
@@ -684,10 +675,9 @@ void FlatAffineValueConstraints::addAffineIfOpDomain(AffineIfOp ifOp) {
   append(cst);
 }
 
-// Searches for a constraint with a non-zero coefficient at 'colIdx' in
+// Searches for a constraint with a non-zero coefficient at `colIdx` in
 // equality (isEq=true) or inequality (isEq=false) constraints.
-// Returns true and sets row found in search in 'rowIdx'.
-// Returns false otherwise.
+// Returns true and sets row found in search in `rowIdx`, false otherwise.
 static bool findConstraintWithNonZeroAt(const FlatAffineConstraints &cst,
                                         unsigned colIdx, bool isEq,
                                         unsigned *rowIdx) {
@@ -704,8 +694,8 @@ static bool findConstraintWithNonZeroAt(const FlatAffineConstraints &cst,
   return false;
 }
 
-// Normalizes the coefficient values across all columns in 'rowIDx' by their
-// GCD in equality or inequality constraints as specified by 'isEq'.
+// Normalizes the coefficient values across all columns in `rowIdx` by their
+// GCD in equality or inequality constraints as specified by `isEq`.
 template <bool isEq>
 static void normalizeConstraintByGCD(FlatAffineConstraints *constraints,
                                      unsigned rowIdx) {
@@ -750,13 +740,9 @@ bool FlatAffineConstraints::hasConsistentState() const {
 
 bool FlatAffineValueConstraints::hasConsistentState() const {
   return FlatAffineConstraints::hasConsistentState() &&
-         ids.size() == getNumIds();
+         values.size() == getNumIds();
 }
 
-/// Checks all rows of equality/inequality constraints for trivial
-/// contradictions (for example: 1 == 0, 0 >= 1), which may have surfaced
-/// after elimination. Returns 'true' if an invalid constraint is found;
-/// 'false' otherwise.
 bool FlatAffineConstraints::hasInvalidConstraint() const {
   assert(hasConsistentState());
   auto check = [&](bool isEq) -> bool {
@@ -787,9 +773,9 @@ bool FlatAffineConstraints::hasInvalidConstraint() const {
   return check(/*isEq=*/false);
 }
 
-// Eliminate identifier from constraint at 'rowIdx' based on coefficient at
-// pivotRow, pivotCol. Columns in range [elimColStart, pivotCol) will not be
-// updated as they have already been eliminated.
+/// Eliminate identifier from constraint at `rowIdx` based on coefficient at
+/// pivotRow, pivotCol. Columns in range [elimColStart, pivotCol) will not be
+/// updated as they have already been eliminated.
 static void eliminateFromConstraint(FlatAffineConstraints *constraints,
                                     unsigned rowIdx, unsigned pivotRow,
                                     unsigned pivotCol, unsigned elimColStart,
@@ -822,8 +808,6 @@ static void eliminateFromConstraint(FlatAffineConstraints *constraints,
   }
 }
 
-// Removes identifiers in column range [idStart, idLimit), and copies any
-// remaining valid data into place, and updates member variables.
 void FlatAffineConstraints::removeIdRange(unsigned idStart, unsigned idLimit) {
   assert(idLimit < getNumCols() && "invalid id limit");
 
@@ -862,7 +846,7 @@ void FlatAffineConstraints::removeIdRange(unsigned idStart, unsigned idLimit) {
 void FlatAffineValueConstraints::removeIdRange(unsigned idStart,
                                                unsigned idLimit) {
   FlatAffineConstraints::removeIdRange(idStart, idLimit);
-  ids.erase(ids.begin() + idStart, ids.begin() + idLimit);
+  values.erase(values.begin() + idStart, values.begin() + idLimit);
 }
 
 /// Returns the position of the identifier that has the minimum <number of lower
@@ -2011,9 +1995,9 @@ FlatAffineValueConstraints::computeAlignedMap(AffineMap map,
   dims.reserve(numDims);
   syms.reserve(numSymbols);
   for (unsigned i = 0; i < numDims; ++i)
-    dims.push_back(ids[i] ? *ids[i] : Value());
+    dims.push_back(values[i] ? *values[i] : Value());
   for (unsigned i = numDims, e = numDims + numSymbols; i < e; ++i)
-    syms.push_back(ids[i] ? *ids[i] : Value());
+    syms.push_back(values[i] ? *values[i] : Value());
 
   AffineMap alignedMap =
       alignAffineMapWithValues(map, operands, dims, syms, newSymsPtr);
@@ -2166,10 +2150,10 @@ void FlatAffineConstraints::addLocalFloorDiv(ArrayRef<int64_t> dividend,
   addInequality(bound);
 }
 
-bool FlatAffineValueConstraints::findId(Value id, unsigned *pos) const {
+bool FlatAffineValueConstraints::findId(Value val, unsigned *pos) const {
   unsigned i = 0;
-  for (const auto &mayBeId : ids) {
-    if (mayBeId.hasValue() && mayBeId.getValue() == id) {
+  for (const auto &mayBeId : values) {
+    if (mayBeId.hasValue() && mayBeId.getValue() == val) {
       *pos = i;
       return true;
     }
@@ -2178,9 +2162,9 @@ bool FlatAffineValueConstraints::findId(Value id, unsigned *pos) const {
   return false;
 }
 
-bool FlatAffineValueConstraints::containsId(Value id) const {
-  return llvm::any_of(ids, [&](const Optional<Value> &mayBeId) {
-    return mayBeId.hasValue() && mayBeId.getValue() == id;
+bool FlatAffineValueConstraints::containsId(Value val) const {
+  return llvm::any_of(values, [&](const Optional<Value> &mayBeId) {
+    return mayBeId.hasValue() && mayBeId.getValue() == val;
   });
 }
 
@@ -2199,7 +2183,7 @@ void FlatAffineConstraints::swapId(unsigned posA, unsigned posB) {
 
 void FlatAffineValueConstraints::swapId(unsigned posA, unsigned posB) {
   FlatAffineConstraints::swapId(posA, posB);
-  std::swap(getId(posA), getId(posB));
+  std::swap(values[posA], values[posB]);
 }
 
 void FlatAffineConstraints::setDimSymbolSeparation(unsigned newSymbolCount) {
@@ -2219,9 +2203,9 @@ void FlatAffineConstraints::setIdToConstant(unsigned pos, int64_t val) {
 
 /// Sets the specified identifier to a constant value; asserts if the id is not
 /// found.
-void FlatAffineValueConstraints::setIdToConstant(Value id, int64_t val) {
+void FlatAffineValueConstraints::setIdToConstant(Value value, int64_t val) {
   unsigned pos;
-  if (!findId(id, &pos))
+  if (!findId(value, &pos))
     // This is a pre-condition for this method.
     assert(0 && "id not found");
   setIdToConstant(pos, val);
@@ -2547,7 +2531,7 @@ void FlatAffineConstraints::print(raw_ostream &os) const {
   os << "(";
   for (unsigned i = 0, e = getNumIds(); i < e; i++) {
     if (auto *valueCstr = dyn_cast<const FlatAffineValueConstraints>(this)) {
-      if (valueCstr->hasIdValue(i))
+      if (valueCstr->hasValue(i))
         os << "Value ";
       else
         os << "None ";
@@ -2647,7 +2631,7 @@ void FlatAffineConstraints::removeTrivialRedundancy() {
 void FlatAffineConstraints::clearAndCopyFrom(
     const FlatAffineConstraints &other) {
   if (auto *otherValueSet = dyn_cast<const FlatAffineValueConstraints>(&other))
-    assert(!otherValueSet->hasIdValues() &&
+    assert(!otherValueSet->hasValues() &&
            "cannot copy associated Values into FlatAffineConstraints");
   // Note: Assigment operator does not vtable pointer, so kind does not change.
   *this = other;
@@ -2660,8 +2644,8 @@ void FlatAffineValueConstraints::clearAndCopyFrom(
     *this = *otherValueSet;
   } else {
     *static_cast<FlatAffineConstraints *>(this) = other;
-    ids.clear();
-    ids.resize(numIds, None);
+    values.clear();
+    values.resize(numIds, None);
   }
 }
 
@@ -2897,15 +2881,15 @@ void FlatAffineConstraints::fourierMotzkinEliminate(
 
 void FlatAffineValueConstraints::fourierMotzkinEliminate(
     unsigned pos, bool darkShadow, bool *isResultIntegerExact) {
-  SmallVector<Optional<Value>, 8> newIds;
-  newIds.reserve(numIds - 1);
-  newIds.append(ids.begin(), ids.begin() + pos);
-  newIds.append(ids.begin() + pos + 1, ids.end());
+  SmallVector<Optional<Value>, 8> newVals;
+  newVals.reserve(numIds - 1);
+  newVals.append(values.begin(), values.begin() + pos);
+  newVals.append(values.begin() + pos + 1, values.end());
   // Note: Base implementation discards all associated Values.
   FlatAffineConstraints::fourierMotzkinEliminate(pos, darkShadow,
                                                  isResultIntegerExact);
-  ids = newIds;
-  assert(getIds().size() == getNumIds());
+  values = newVals;
+  assert(values.size() == getNumIds());
 }
 
 void FlatAffineConstraints::projectOut(unsigned pos, unsigned num) {
@@ -2943,9 +2927,9 @@ void FlatAffineConstraints::projectOut(unsigned pos, unsigned num) {
   normalizeConstraintsByGCD();
 }
 
-void FlatAffineValueConstraints::projectOut(Value id) {
+void FlatAffineValueConstraints::projectOut(Value val) {
   unsigned pos;
-  bool ret = findId(id, &pos);
+  bool ret = findId(val, &pos);
   assert(ret);
   (void)ret;
   fourierMotzkinEliminate(pos);
@@ -3120,9 +3104,9 @@ FlatAffineConstraints::unionBoundingBox(const FlatAffineConstraints &otherCst) {
 LogicalResult FlatAffineValueConstraints::unionBoundingBox(
     const FlatAffineValueConstraints &otherCst) {
   assert(otherCst.getNumDimIds() == numDims && "dims mismatch");
-  assert(otherCst.getIds()
+  assert(otherCst.getMaybeValues()
              .slice(0, getNumDimIds())
-             .equals(getIds().slice(0, getNumDimIds())) &&
+             .equals(getMaybeValues().slice(0, getNumDimIds())) &&
          "dim values mismatch");
   assert(otherCst.getNumLocalIds() == 0 && "local ids not supported here");
   assert(getNumLocalIds() == 0 && "local ids not supported yet here");
@@ -3208,9 +3192,9 @@ void FlatAffineValueConstraints::getIneqAsAffineValueMap(
 
   // Get the values to bind to this affine expr (all dims and symbols).
   SmallVector<Value, 4> operands;
-  getIdValues(0, pos, &operands);
+  getValues(0, pos, &operands);
   SmallVector<Value, 4> trailingOperands;
-  getIdValues(pos + 1, getNumDimAndSymbolIds(), &trailingOperands);
+  getValues(pos + 1, getNumDimAndSymbolIds(), &trailingOperands);
   operands.append(trailingOperands.begin(), trailingOperands.end());
   vmap.reset(AffineMap::get(numDims - 1, numSyms, boundExpr), operands);
 }

diff  --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp
index 328a5f4967664..93b36929999d9 100644
--- a/mlir/lib/Analysis/Utils.cpp
+++ b/mlir/lib/Analysis/Utils.cpp
@@ -558,7 +558,7 @@ LogicalResult MemRefRegion::compute(Operation *op, unsigned loopDepth,
   assert(loopDepth <= enclosingIVs.size() && "invalid loop depth");
   enclosingIVs.resize(loopDepth);
   SmallVector<Value, 4> ids;
-  cst.getIdValues(cst.getNumDimIds(), cst.getNumDimAndSymbolIds(), &ids);
+  cst.getValues(cst.getNumDimIds(), cst.getNumDimAndSymbolIds(), &ids);
   for (auto id : ids) {
     AffineForOp iv;
     if ((iv = getForInductionVarOwner(id)) &&
@@ -762,7 +762,7 @@ static Operation *getInstAtPosition(ArrayRef<unsigned> positions,
 static LogicalResult addMissingLoopIVBounds(SmallPtrSet<Value, 8> &ivs,
                                             FlatAffineValueConstraints *cst) {
   for (unsigned i = 0, e = cst->getNumDimIds(); i < e; ++i) {
-    auto value = cst->getIdValue(i);
+    auto value = cst->getValue(i);
     if (ivs.count(value) == 0) {
       assert(isForInductionVar(value));
       auto loop = getForInductionVarOwner(value);
@@ -877,10 +877,10 @@ mlir::computeSliceUnion(ArrayRef<Operation *> opsA, ArrayRef<Operation *> opsB,
         // system.
         SmallPtrSet<Value, 8> sliceUnionIVs;
         for (unsigned k = 0, l = sliceUnionCst.getNumDimIds(); k < l; ++k)
-          sliceUnionIVs.insert(sliceUnionCst.getIdValue(k));
+          sliceUnionIVs.insert(sliceUnionCst.getValue(k));
         SmallPtrSet<Value, 8> tmpSliceIVs;
         for (unsigned k = 0, l = tmpSliceCst.getNumDimIds(); k < l; ++k)
-          tmpSliceIVs.insert(tmpSliceCst.getIdValue(k));
+          tmpSliceIVs.insert(tmpSliceCst.getValue(k));
 
         sliceUnionCst.mergeAndAlignIdsWithOther(/*offset=*/0, &tmpSliceCst);
 
@@ -938,13 +938,13 @@ mlir::computeSliceUnion(ArrayRef<Operation *> opsA, ArrayRef<Operation *> opsB,
 
   // Add slice bound operands of union.
   SmallVector<Value, 4> sliceBoundOperands;
-  sliceUnionCst.getIdValues(numSliceLoopIVs,
-                            sliceUnionCst.getNumDimAndSymbolIds(),
-                            &sliceBoundOperands);
+  sliceUnionCst.getValues(numSliceLoopIVs,
+                          sliceUnionCst.getNumDimAndSymbolIds(),
+                          &sliceBoundOperands);
 
   // Copy src loop IVs from 'sliceUnionCst' to 'sliceUnion'.
   sliceUnion->ivs.clear();
-  sliceUnionCst.getIdValues(0, numSliceLoopIVs, &sliceUnion->ivs);
+  sliceUnionCst.getValues(0, numSliceLoopIVs, &sliceUnion->ivs);
 
   // Set loop nest insertion point to block start at 'loopDepth'.
   sliceUnion->insertPoint =
@@ -1068,8 +1068,8 @@ void mlir::getComputationSliceState(
   // Add slice loop IV values to 'sliceState'.
   unsigned offset = isBackwardSlice ? 0 : loopDepth;
   unsigned numSliceLoopIVs = isBackwardSlice ? numSrcLoopIVs : numDstLoopIVs;
-  dependenceConstraints->getIdValues(offset, offset + numSliceLoopIVs,
-                                     &sliceState->ivs);
+  dependenceConstraints->getValues(offset, offset + numSliceLoopIVs,
+                                   &sliceState->ivs);
 
   // Set up lower/upper bound affine maps for the slice.
   sliceState->lbs.resize(numSliceLoopIVs, AffineMap());
@@ -1085,7 +1085,7 @@ void mlir::getComputationSliceState(
   unsigned numDimsAndSymbols = dependenceConstraints->getNumDimAndSymbolIds();
   for (unsigned i = 0; i < numDimsAndSymbols; ++i) {
     if (i < offset || i >= offset + numSliceLoopIVs) {
-      sliceBoundOperands.push_back(dependenceConstraints->getIdValue(i));
+      sliceBoundOperands.push_back(dependenceConstraints->getValue(i));
     }
   }
 

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
index b6fbdb7612599..24a202f27f491 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
@@ -769,7 +769,7 @@ hoistPaddingOnTensorsPrerequisites(linalg::PadTensorOp padTensorOp, int nLevels,
     return failure();
 
   SmallVector<Value> allValues;
-  constraints.getAllIdValues(&allValues);
+  constraints.getAllValues(&allValues);
   SmallVector<Value> allNonLoopValues(allValues.begin() + numLoops,
                                       allValues.end());
 

diff  --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp
index 7026ad0166369..c19c887a593d6 100644
--- a/mlir/lib/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Transforms/LoopFusion.cpp
@@ -921,7 +921,7 @@ static Value createPrivateMemRef(AffineForOp forOp, Operation *srcStoreOpInst,
   // on; this would correspond to loop IVs surrounding the level at which the
   // slice is being materialized.
   SmallVector<Value, 8> outerIVs;
-  cst->getIdValues(rank, cst->getNumIds(), &outerIVs);
+  cst->getValues(rank, cst->getNumIds(), &outerIVs);
 
   // Build 'rank' AffineExprs from MemRefRegion 'lbs'
   SmallVector<AffineExpr, 4> offsets;

diff  --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp
index fcca1ae0bd0f9..2c9cd3ce6bc44 100644
--- a/mlir/lib/Transforms/Utils/LoopUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp
@@ -2206,7 +2206,7 @@ findHighestBlockForPlacement(const MemRefRegion &region, Block &block,
                              Block::iterator *copyOutPlacementStart) {
   const auto *cst = region.getConstraints();
   SmallVector<Value, 4> symbols;
-  cst->getIdValues(cst->getNumDimIds(), cst->getNumDimAndSymbolIds(), &symbols);
+  cst->getValues(cst->getNumDimIds(), cst->getNumDimAndSymbolIds(), &symbols);
 
   SmallVector<AffineForOp, 4> enclosingFors;
   getLoopIVs(*block.begin(), &enclosingFors);
@@ -2445,7 +2445,7 @@ static LogicalResult generateCopy(
   // on; these typically include loop IVs surrounding the level at which the
   // copy generation is being done or other valid symbols in MLIR.
   SmallVector<Value, 8> regionSymbols;
-  cst->getIdValues(rank, cst->getNumIds(), &regionSymbols);
+  cst->getValues(rank, cst->getNumIds(), &regionSymbols);
 
   // Construct the index expressions for the fast memory buffer. The index
   // expression for a particular dimension of the fast buffer is obtained by
@@ -2689,7 +2689,7 @@ static bool getFullMemRefAsRegion(Operation *op, unsigned numParamLoopIVs,
   SmallVector<Value, 4> symbols;
   extractForInductionVars(ivs, &symbols);
   regionCst->reset(rank, numParamLoopIVs, 0);
-  regionCst->setIdValues(rank, rank + numParamLoopIVs, symbols);
+  regionCst->setValues(rank, rank + numParamLoopIVs, symbols);
 
   // Memref dim sizes provide the bounds.
   for (unsigned d = 0; d < rank; d++) {
@@ -3068,7 +3068,7 @@ static AffineIfOp createSeparationCondition(MutableArrayRef<AffineForOp> loops,
     return nullptr;
 
   SmallVector<Value, 4> setOperands;
-  cst.getIdValues(0, cst.getNumDimAndSymbolIds(), &setOperands);
+  cst.getValues(0, cst.getNumDimAndSymbolIds(), &setOperands);
   canonicalizeSetAndOperands(&ifCondSet, &setOperands);
   return b.create<AffineIfOp>(loops[0].getLoc(), ifCondSet, setOperands,
                               /*withElseRegion=*/true);


        


More information about the Mlir-commits mailing list