[Mlir-commits] [mlir] c872e6c - [mlir][Interfaces][NFC] ValueBoundsConstraintSet: Simplify constructor

Matthias Springer llvmlistbot at llvm.org
Thu May 25 10:02:27 PDT 2023


Author: Matthias Springer
Date: 2023-05-25T18:56:24+02:00
New Revision: c872e6c743eab96cc58068990592177a6ee58cde

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

LOG: [mlir][Interfaces][NFC] ValueBoundsConstraintSet: Simplify constructor

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

Added: 
    

Modified: 
    mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
    mlir/lib/Interfaces/ValueBoundsOpInterface.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
index 29e1cf53abbae..c4d446e2ca4bc 100644
--- a/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
+++ b/mlir/include/mlir/Interfaces/ValueBoundsOpInterface.h
@@ -183,7 +183,7 @@ class ValueBoundsConstraintSet {
   /// An index-typed value or the dimension of a shaped-type value.
   using ValueDim = std::pair<Value, int64_t>;
 
-  ValueBoundsConstraintSet(Value value, std::optional<int64_t> dim);
+  ValueBoundsConstraintSet(MLIRContext *ctx);
 
   /// Iteratively process all elements on the worklist until an index-typed
   /// value or shaped value meets `stopCondition`. Such values are not processed

diff  --git a/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp b/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
index 1fbe42cd114b0..28f34a9644b29 100644
--- a/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
+++ b/mlir/lib/Interfaces/ValueBoundsOpInterface.cpp
@@ -39,11 +39,8 @@ static std::optional<int64_t> getConstantIntValue(OpFoldResult ofr) {
   return std::nullopt;
 }
 
-ValueBoundsConstraintSet::ValueBoundsConstraintSet(Value value,
-                                                   std::optional<int64_t> dim)
-    : builder(value.getContext()) {
-  insert(value, dim, /*isSymbol=*/false);
-}
+ValueBoundsConstraintSet::ValueBoundsConstraintSet(MLIRContext *ctx)
+    : builder(ctx) {}
 
 #ifndef NDEBUG
 static void assertValidValueDim(Value value, std::optional<int64_t> dim) {
@@ -246,7 +243,8 @@ LogicalResult ValueBoundsConstraintSet::computeBound(
   // Process the backward slice of `value` (i.e., reverse use-def chain) until
   // `stopCondition` is met.
   ValueDim valueDim = std::make_pair(value, dim.value_or(kIndexValue));
-  ValueBoundsConstraintSet cstr(value, dim);
+  ValueBoundsConstraintSet cstr(value.getContext());
+  int64_t pos = cstr.insert(value, dim, /*isSymbol=*/false);
   cstr.processWorklist(stopCondition);
 
   // Project out all variables (apart from `valueDim`) that do not match the
@@ -261,7 +259,6 @@ LogicalResult ValueBoundsConstraintSet::computeBound(
   });
 
   // Compute lower and upper bounds for `valueDim`.
-  int64_t pos = cstr.getPos(value, dim);
   SmallVector<AffineMap> lb(1), ub(1);
   cstr.cstr.getSliceBounds(pos, 1, value.getContext(), &lb, &ub,
                            /*getClosedUB=*/true);
@@ -411,8 +408,8 @@ FailureOr<int64_t> ValueBoundsConstraintSet::computeConstantBound(
 
   // Process the backward slice of `value` (i.e., reverse use-def chain) until
   // `stopCondition` is met.
-  ValueBoundsConstraintSet cstr(value, dim);
-  int64_t pos = cstr.getPos(value, dim);
+  ValueBoundsConstraintSet cstr(value.getContext());
+  int64_t pos = cstr.insert(value, dim, /*isSymbol=*/false);
   if (stopCondition) {
     cstr.processWorklist(stopCondition);
   } else {


        


More information about the Mlir-commits mailing list