[Mlir-commits] [mlir] ee7c474 - [mlir][affine][analysis][NFC] Simplify FlatAffineConstraints API
Matthias Springer
llvmlistbot at llvm.org
Wed Mar 15 01:30:34 PDT 2023
Author: Matthias Springer
Date: 2023-03-15T09:22:53+01:00
New Revision: ee7c4741506c20ccee0257dae745550135108d7c
URL: https://github.com/llvm/llvm-project/commit/ee7c4741506c20ccee0257dae745550135108d7c
DIFF: https://github.com/llvm/llvm-project/commit/ee7c4741506c20ccee0257dae745550135108d7c.diff
LOG: [mlir][affine][analysis][NFC] Simplify FlatAffineConstraints API
* Remove `reset` function. Use copy assignment directly (instead of within `reset`).
* Fix potential `nullptr` dereference in `getFlattenedAffineExprs`.
* Make constraint set optional in `checkMemrefAccessDependence`.
Differential Revision: https://reviews.llvm.org/D145935
Added:
Modified:
mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h
mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
mlir/lib/Dialect/Affine/Analysis/Utils.cpp
mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp
mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
mlir/lib/Dialect/Affine/Utils/Utils.cpp
mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
index 527faf3d41812..347be26325e5a 100644
--- a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
+++ b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
@@ -203,27 +203,27 @@ class IntegerRelation {
/// Get the number of vars of the specified kind.
unsigned getNumVarKind(VarKind kind) const {
return space.getNumVarKind(kind);
- };
+ }
/// Return the index at which the specified kind of vars starts.
unsigned getVarKindOffset(VarKind kind) const {
return space.getVarKindOffset(kind);
- };
+ }
/// Return the index at Which the specified kind of vars ends.
unsigned getVarKindEnd(VarKind kind) const {
return space.getVarKindEnd(kind);
- };
+ }
/// Get the number of elements of the specified kind in the range
/// [varStart, varLimit).
unsigned getVarKindOverlap(VarKind kind, unsigned varStart,
unsigned varLimit) const {
return space.getVarKindOverlap(kind, varStart, varLimit);
- };
+ }
/// Return the VarKind of the var at the specified position.
- VarKind getVarKindAt(unsigned pos) const { return space.getVarKindAt(pos); };
+ VarKind getVarKindAt(unsigned pos) const { return space.getVarKindAt(pos); }
/// The struct CountsSnapshot stores the count of each VarKind, and also of
/// each constraint type. getCounts() returns a CountsSnapshot object
@@ -493,7 +493,7 @@ class IntegerRelation {
if (ub)
*ub = getInt64Vec(ubMPInt);
if (boundFloorDivisor)
- *boundFloorDivisor = int64_t(boundFloorDivisorMPInt);
+ *boundFloorDivisor = static_cast<int64_t>(boundFloorDivisorMPInt);
return llvm::transformOptional(result, int64FromMPInt);
}
diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h b/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h
index 5f728516ac390..826c740c90cff 100644
--- a/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h
+++ b/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h
@@ -167,8 +167,9 @@ struct DependenceResult {
DependenceResult checkMemrefAccessDependence(
const MemRefAccess &srcAccess, const MemRefAccess &dstAccess,
- unsigned loopDepth, FlatAffineValueConstraints *dependenceConstraints,
- SmallVector<DependenceComponent, 2> *dependenceComponents,
+ unsigned loopDepth,
+ FlatAffineValueConstraints *dependenceConstraints = nullptr,
+ SmallVector<DependenceComponent, 2> *dependenceComponents = nullptr,
bool allowRAR = false);
/// Utility function that returns true if the provided DependenceResult
diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h b/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
index 0f2ed99136039..1b302f55422d8 100644
--- a/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
+++ b/mlir/include/mlir/Dialect/Affine/Analysis/AffineStructures.h
@@ -43,12 +43,14 @@ class MultiAffineFunction;
class FlatAffineValueConstraints : public presburger::IntegerPolyhedron {
public:
/// Constructs a constraint system reserving memory for the specified number
- /// of constraints and variables.
+ /// of constraints and variables. `valArgs` are the optional SSA values
+ /// associated with each dimension/symbol. These must either be empty or match
+ /// the number of dimensions and symbols.
FlatAffineValueConstraints(unsigned numReservedInequalities,
unsigned numReservedEqualities,
unsigned numReservedCols, unsigned numDims,
unsigned numSymbols, unsigned numLocals,
- ArrayRef<std::optional<Value>> valArgs = {})
+ ArrayRef<std::optional<Value>> valArgs)
: IntegerPolyhedron(numReservedInequalities, numReservedEqualities,
numReservedCols,
presburger::PresburgerSpace::getSetSpace(
@@ -62,11 +64,48 @@ class FlatAffineValueConstraints : public presburger::IntegerPolyhedron {
values.append(valArgs.begin(), valArgs.end());
}
- /// Constructs a constraint system with the specified number of
+ /// Constructs a constraint system reserving memory for the specified number
+ /// of constraints and variables. `valArgs` are the optional SSA values
+ /// associated with each dimension/symbol. These must either be empty or match
+ /// the number of dimensions and symbols.
+ FlatAffineValueConstraints(unsigned numReservedInequalities,
+ unsigned numReservedEqualities,
+ unsigned numReservedCols, unsigned numDims,
+ unsigned numSymbols, unsigned numLocals,
+ ArrayRef<Value> valArgs = {})
+ : IntegerPolyhedron(numReservedInequalities, numReservedEqualities,
+ numReservedCols,
+ presburger::PresburgerSpace::getSetSpace(
+ numDims, numSymbols, numLocals)) {
+ assert(numReservedCols >= getNumVars() + 1);
+ assert(valArgs.empty() || valArgs.size() == getNumDimAndSymbolVars());
+ values.reserve(numReservedCols);
+ if (valArgs.empty())
+ values.resize(getNumDimAndSymbolVars(), std::nullopt);
+ else
+ values.append(valArgs.begin(), valArgs.end());
+ }
+
+ /// Constructs a constraint system with the specified number of dimensions
+ /// and symbols. `valArgs` are the optional SSA values associated with each
+ /// dimension/symbol. These must either be empty or match the number of
+ /// dimensions and symbols.
+ FlatAffineValueConstraints(unsigned numDims, unsigned numSymbols,
+ unsigned numLocals,
+ ArrayRef<std::optional<Value>> valArgs)
+ : FlatAffineValueConstraints(/*numReservedInequalities=*/0,
+ /*numReservedEqualities=*/0,
+ /*numReservedCols=*/numDims + numSymbols +
+ numLocals + 1,
+ numDims, numSymbols, numLocals, valArgs) {}
+
+ /// Constructs a constraint system with the specified number of dimensions
+ /// and symbols. `valArgs` are the optional SSA values associated with each
+ /// dimension/symbol. These must either be empty or match the number of
/// dimensions and symbols.
FlatAffineValueConstraints(unsigned numDims = 0, unsigned numSymbols = 0,
unsigned numLocals = 0,
- ArrayRef<std::optional<Value>> valArgs = {})
+ ArrayRef<Value> valArgs = {})
: FlatAffineValueConstraints(/*numReservedInequalities=*/0,
/*numReservedEqualities=*/0,
/*numReservedCols=*/numDims + numSymbols +
@@ -83,11 +122,6 @@ class FlatAffineValueConstraints : public presburger::IntegerPolyhedron {
values.append(valArgs.begin(), valArgs.end());
}
- /// Create a flat affine constraint system from an AffineValueMap or a list of
- /// these. The constructed system will only include equalities.
- explicit FlatAffineValueConstraints(const AffineValueMap &avm);
- explicit FlatAffineValueConstraints(ArrayRef<const AffineValueMap *> avmRef);
-
/// Creates an affine constraint system from an IntegerSet.
explicit FlatAffineValueConstraints(IntegerSet set, ValueRange operands = {});
@@ -112,19 +146,6 @@ class FlatAffineValueConstraints : public presburger::IntegerPolyhedron {
return cst->getKind() == Kind::FlatAffineValueConstraints;
}
- /// Clears any existing data and reserves memory for the specified
- /// constraints.
- void reset(unsigned numReservedInequalities, unsigned numReservedEqualities,
- unsigned numReservedCols, unsigned numDims, unsigned numSymbols,
- unsigned numLocals = 0);
- void reset(unsigned numDims = 0, unsigned numSymbols = 0,
- unsigned numLocals = 0);
- void reset(unsigned numReservedInequalities, unsigned numReservedEqualities,
- unsigned numReservedCols, unsigned numDims, unsigned numSymbols,
- unsigned numLocals, ArrayRef<Value> valArgs);
- void reset(unsigned numDims, unsigned numSymbols, unsigned numLocals,
- ArrayRef<Value> valArgs);
-
/// Clones this object.
std::unique_ptr<FlatAffineValueConstraints> clone() const;
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
index 9e0dbee83b76b..d7720a052e0dd 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp
@@ -172,10 +172,8 @@ bool mlir::isLoopMemoryParallel(AffineForOp forOp) {
MemRefAccess srcAccess(srcOp);
for (auto *dstOp : loadAndStoreOps) {
MemRefAccess dstAccess(dstOp);
- FlatAffineValueConstraints dependenceConstraints;
- DependenceResult result = checkMemrefAccessDependence(
- srcAccess, dstAccess, depth, &dependenceConstraints,
- /*dependenceComponents=*/nullptr);
+ DependenceResult result =
+ checkMemrefAccessDependence(srcAccess, dstAccess, depth);
if (result.value != DependenceResult::NoDependence)
return false;
}
@@ -260,7 +258,8 @@ LogicalResult mlir::getIndexSet(MutableArrayRef<Operation *> ops,
}
extractInductionVars(loopOps, indices);
// Reset while associating Values in 'indices' to the domain.
- domain->reset(numDims, /*numSymbols=*/0, /*numLocals=*/0, indices);
+ *domain = FlatAffineValueConstraints(numDims, /*numSymbols=*/0,
+ /*numLocals=*/0, indices);
for (Operation *op : ops) {
// Add constraints from forOp's bounds.
if (AffineForOp forOp = dyn_cast<AffineForOp>(op)) {
@@ -651,23 +650,24 @@ DependenceResult mlir::checkMemrefAccessDependence(
// memory locations.
dstRel.inverse();
dstRel.compose(srcRel);
- *dependenceConstraints = dstRel;
// Add 'src' happens before 'dst' ordering constraints.
- addOrderingConstraints(srcDomain, dstDomain, loopDepth,
- dependenceConstraints);
+ addOrderingConstraints(srcDomain, dstDomain, loopDepth, &dstRel);
// Return 'NoDependence' if the solution space is empty: no dependence.
- if (dependenceConstraints->isEmpty())
+ if (dstRel.isEmpty())
return DependenceResult::NoDependence;
// Compute dependence direction vector and return true.
if (dependenceComponents != nullptr)
- computeDirectionVector(srcDomain, dstDomain, loopDepth,
- dependenceConstraints, dependenceComponents);
+ computeDirectionVector(srcDomain, dstDomain, loopDepth, &dstRel,
+ dependenceComponents);
LLVM_DEBUG(llvm::dbgs() << "Dependence polyhedron:\n");
- LLVM_DEBUG(dependenceConstraints->dump());
+ LLVM_DEBUG(dstRel.dump());
+
+ if (dependenceConstraints)
+ *dependenceConstraints = dstRel;
return DependenceResult::HasDependence;
}
@@ -692,12 +692,12 @@ void mlir::getDependenceComponents(
auto *dstOp = loadAndStoreOps[j];
MemRefAccess dstAccess(dstOp);
- FlatAffineValueConstraints dependenceConstraints;
SmallVector<DependenceComponent, 2> depComps;
// TODO: Explore whether it would be profitable to pre-compute and store
// deps instead of repeatedly checking.
DependenceResult result = checkMemrefAccessDependence(
- srcAccess, dstAccess, d, &dependenceConstraints, &depComps);
+ srcAccess, dstAccess, d, /*dependenceConstraints=*/nullptr,
+ &depComps);
if (hasDependence(result))
depCompsVec->push_back(depComps);
}
diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
index 22a98f01fc5c0..9c9d089416c5e 100644
--- a/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp
@@ -75,7 +75,8 @@ getFlattenedAffineExprs(ArrayRef<AffineExpr> exprs, unsigned numDims,
std::vector<SmallVector<int64_t, 8>> *flattenedExprs,
FlatAffineValueConstraints *localVarCst) {
if (exprs.empty()) {
- localVarCst->reset(numDims, numSymbols);
+ if (localVarCst)
+ *localVarCst = FlatAffineValueConstraints(numDims, numSymbols);
return success();
}
@@ -120,7 +121,9 @@ LogicalResult mlir::getFlattenedAffineExprs(
AffineMap map, std::vector<SmallVector<int64_t, 8>> *flattenedExprs,
FlatAffineValueConstraints *localVarCst) {
if (map.getNumResults() == 0) {
- localVarCst->reset(map.getNumDims(), map.getNumSymbols());
+ if (localVarCst)
+ *localVarCst =
+ FlatAffineValueConstraints(map.getNumDims(), map.getNumSymbols());
return success();
}
return ::getFlattenedAffineExprs(map.getResults(), map.getNumDims(),
@@ -132,7 +135,9 @@ LogicalResult mlir::getFlattenedAffineExprs(
IntegerSet set, std::vector<SmallVector<int64_t, 8>> *flattenedExprs,
FlatAffineValueConstraints *localVarCst) {
if (set.getNumConstraints() == 0) {
- localVarCst->reset(set.getNumDims(), set.getNumSymbols());
+ if (localVarCst)
+ *localVarCst =
+ FlatAffineValueConstraints(set.getNumDims(), set.getNumSymbols());
return success();
}
return ::getFlattenedAffineExprs(set.getConstraints(), set.getNumDims(),
@@ -231,50 +236,6 @@ FlatAffineValueConstraints::getHyperrectangular(ValueRange ivs, ValueRange lbs,
return res;
}
-void FlatAffineValueConstraints::reset(unsigned numReservedInequalities,
- unsigned numReservedEqualities,
- unsigned newNumReservedCols,
- unsigned newNumDims,
- unsigned newNumSymbols,
- unsigned newNumLocals) {
- assert(newNumReservedCols >= newNumDims + newNumSymbols + newNumLocals + 1 &&
- "minimum 1 column");
- *this = FlatAffineValueConstraints(numReservedInequalities,
- numReservedEqualities, newNumReservedCols,
- newNumDims, newNumSymbols, newNumLocals);
-}
-
-void FlatAffineValueConstraints::reset(unsigned newNumDims,
- unsigned newNumSymbols,
- unsigned newNumLocals) {
- reset(/*numReservedInequalities=*/0, /*numReservedEqualities=*/0,
- /*numReservedCols=*/newNumDims + newNumSymbols + newNumLocals + 1,
- newNumDims, newNumSymbols, newNumLocals);
-}
-
-void FlatAffineValueConstraints::reset(
- unsigned numReservedInequalities, unsigned numReservedEqualities,
- unsigned newNumReservedCols, unsigned newNumDims, unsigned newNumSymbols,
- unsigned newNumLocals, ArrayRef<Value> valArgs) {
- assert(newNumReservedCols >= newNumDims + newNumSymbols + newNumLocals + 1 &&
- "minimum 1 column");
- SmallVector<std::optional<Value>, 8> newVals;
- if (!valArgs.empty())
- newVals.assign(valArgs.begin(), valArgs.end());
-
- *this = FlatAffineValueConstraints(
- numReservedInequalities, numReservedEqualities, newNumReservedCols,
- newNumDims, newNumSymbols, newNumLocals, newVals);
-}
-
-void FlatAffineValueConstraints::reset(unsigned newNumDims,
- unsigned newNumSymbols,
- unsigned newNumLocals,
- ArrayRef<Value> valArgs) {
- reset(0, 0, newNumDims + newNumSymbols + newNumLocals + 1, newNumDims,
- newNumSymbols, newNumLocals, valArgs);
-}
-
unsigned FlatAffineValueConstraints::appendDimVar(ValueRange vals) {
unsigned pos = getNumDimVars();
return insertVar(VarKind::SetDim, pos, vals);
diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
index 0ae40826de8bd..252e77ef48891 100644
--- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
@@ -65,7 +65,8 @@ void mlir::getEnclosingAffineOps(Operation &op,
LogicalResult
ComputationSliceState::getSourceAsConstraints(FlatAffineValueConstraints &cst) {
assert(!ivs.empty() && "Cannot have a slice without its IVs");
- cst.reset(/*numDims=*/ivs.size(), /*numSymbols=*/0, /*numLocals=*/0, ivs);
+ cst = FlatAffineValueConstraints(/*numDims=*/ivs.size(), /*numSymbols=*/0,
+ /*numLocals=*/0, ivs);
for (Value iv : ivs) {
AffineForOp loop = getForInductionVarOwner(iv);
assert(loop && "Expected affine for");
@@ -87,7 +88,7 @@ ComputationSliceState::getAsConstraints(FlatAffineValueConstraints *cst) {
SmallVector<Value, 4> values(ivs);
// Append 'ivs' then 'operands' to 'values'.
values.append(lbOperands[0].begin(), lbOperands[0].end());
- cst->reset(numDims, numSymbols, 0, values);
+ *cst = FlatAffineValueConstraints(numDims, numSymbols, 0, values);
// Add loop bound constraints for values which are loop IVs of the destination
// of fusion and equality constraints for symbols which are constants.
@@ -293,9 +294,9 @@ std::optional<bool> ComputationSliceState::isMaximal() const {
return isMaximalFastCheck;
// Create constraints for the src loop nest being sliced.
- FlatAffineValueConstraints srcConstraints;
- srcConstraints.reset(/*numDims=*/ivs.size(), /*numSymbols=*/0,
- /*numLocals=*/0, ivs);
+ FlatAffineValueConstraints srcConstraints(/*numDims=*/ivs.size(),
+ /*numSymbols=*/0,
+ /*numLocals=*/0, ivs);
for (Value iv : ivs) {
AffineForOp loop = getForInductionVarOwner(iv);
assert(loop && "Expected affine for");
@@ -305,7 +306,7 @@ std::optional<bool> ComputationSliceState::isMaximal() const {
// Create constraints for the slice using the dst loop nest information. We
// retrieve existing dst loops from the lbOperands.
- SmallVector<Value, 8> consumerIVs;
+ SmallVector<Value> consumerIVs;
for (Value lbOp : lbOperands[0])
if (getForInductionVarOwner(lbOp))
consumerIVs.push_back(lbOp);
@@ -315,9 +316,9 @@ std::optional<bool> ComputationSliceState::isMaximal() const {
for (int i = consumerIVs.size(), end = ivs.size(); i < end; ++i)
consumerIVs.push_back(Value());
- FlatAffineValueConstraints sliceConstraints;
- sliceConstraints.reset(/*numDims=*/consumerIVs.size(), /*numSymbols=*/0,
- /*numLocals=*/0, consumerIVs);
+ FlatAffineValueConstraints sliceConstraints(/*numDims=*/consumerIVs.size(),
+ /*numSymbols=*/0,
+ /*numLocals=*/0, consumerIVs);
if (failed(sliceConstraints.addDomainFromSliceMaps(lbs, ubs, lbOperands[0])))
return std::nullopt;
@@ -464,7 +465,7 @@ LogicalResult MemRefRegion::compute(Operation *op, unsigned loopDepth,
// The first 'loopDepth' IVs are symbols for this region.
ivs.resize(loopDepth);
// A 0-d memref has a 0-d region.
- cst.reset(rank, loopDepth, /*numLocals=*/0, ivs);
+ cst = FlatAffineValueConstraints(rank, loopDepth, /*numLocals=*/0, ivs);
return success();
}
@@ -495,7 +496,7 @@ LogicalResult MemRefRegion::compute(Operation *op, unsigned loopDepth,
// We'll first associate the dims and symbols of the access map to the dims
// and symbols resp. of cst. This will change below once cst is
// fully constructed out.
- cst.reset(numDims, numSymbols, 0, operands);
+ cst = FlatAffineValueConstraints(numDims, numSymbols, 0, operands);
// Add equality constraints.
// Add inequalities for loop lower/upper bounds.
diff --git a/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp
index 366c090d0dcf4..624b79f65d429 100644
--- a/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/LoopFusionUtils.cpp
@@ -225,11 +225,9 @@ static unsigned getMaxLoopDepth(ArrayRef<Operation *> srcOps,
unsigned numCommonLoops =
getNumCommonSurroundingLoops(*srcOpInst, *dstOpInst);
for (unsigned d = 1; d <= numCommonLoops + 1; ++d) {
- FlatAffineValueConstraints dependenceConstraints;
// TODO: Cache dependence analysis results, check cache here.
- DependenceResult result = checkMemrefAccessDependence(
- srcAccess, dstAccess, d, &dependenceConstraints,
- /*dependenceComponents=*/nullptr);
+ DependenceResult result =
+ checkMemrefAccessDependence(srcAccess, dstAccess, d);
if (hasDependence(result)) {
// Store minimum loop depth and break because we want the min 'd' at
// which there is a dependence.
diff --git a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
index e7550d246e392..bcd87fcc570a3 100644
--- a/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
@@ -378,7 +378,6 @@ checkTilingLegalityImpl(MutableArrayRef<mlir::AffineForOp> origLoops) {
unsigned numOps = loadAndStoreOps.size();
unsigned numLoops = origLoops.size();
- FlatAffineValueConstraints dependenceConstraints;
for (unsigned d = 1; d <= numLoops + 1; ++d) {
for (unsigned i = 0; i < numOps; ++i) {
Operation *srcOp = loadAndStoreOps[i];
@@ -388,9 +387,9 @@ checkTilingLegalityImpl(MutableArrayRef<mlir::AffineForOp> origLoops) {
MemRefAccess dstAccess(dstOp);
SmallVector<DependenceComponent, 2> depComps;
- dependenceConstraints.reset();
DependenceResult result = checkMemrefAccessDependence(
- srcAccess, dstAccess, d, &dependenceConstraints, &depComps);
+ srcAccess, dstAccess, d, /*dependenceConstraints=*/nullptr,
+ &depComps);
// Skip if there is no dependence in this case.
if (!hasDependence(result))
@@ -2362,7 +2361,7 @@ static bool getFullMemRefAsRegion(Operation *op, unsigned numParamLoopIVs,
ivs.resize(numParamLoopIVs);
SmallVector<Value, 4> symbols;
extractForInductionVars(ivs, &symbols);
- regionCst->reset(rank, numParamLoopIVs, 0);
+ *regionCst = FlatAffineValueConstraints(rank, numParamLoopIVs, 0);
regionCst->setValues(rank, rank + numParamLoopIVs, symbols);
// Memref dim sizes provide the bounds.
diff --git a/mlir/lib/Dialect/Affine/Utils/Utils.cpp b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
index 5830e8cef99a0..50405953e05bd 100644
--- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
@@ -660,10 +660,8 @@ static bool mustReachAtInnermost(const MemRefAccess &srcAccess,
unsigned nsLoops =
getNumCommonSurroundingLoops(*srcAccess.opInst, *destAccess.opInst);
- FlatAffineValueConstraints dependenceConstraints;
- DependenceResult result = checkMemrefAccessDependence(
- srcAccess, destAccess, nsLoops + 1, &dependenceConstraints,
- /*dependenceComponents=*/nullptr);
+ DependenceResult result =
+ checkMemrefAccessDependence(srcAccess, destAccess, nsLoops + 1);
return hasDependence(result);
}
diff --git a/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp b/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
index 7c384e1a48ccd..7ddcfdde06c0e 100644
--- a/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
+++ b/mlir/test/lib/Analysis/TestMemRefDependenceCheck.cpp
@@ -81,10 +81,9 @@ static void checkDependences(ArrayRef<Operation *> loadsAndStores) {
unsigned numCommonLoops =
getNumCommonSurroundingLoops(*srcOpInst, *dstOpInst);
for (unsigned d = 1; d <= numCommonLoops + 1; ++d) {
- FlatAffineValueConstraints dependenceConstraints;
SmallVector<DependenceComponent, 2> dependenceComponents;
DependenceResult result = checkMemrefAccessDependence(
- srcAccess, dstAccess, d, &dependenceConstraints,
+ srcAccess, dstAccess, d, /*dependenceConstraints=*/nullptr,
&dependenceComponents);
if (result.value == DependenceResult::Failure) {
srcOpInst->emitError("dependence check failed");
More information about the Mlir-commits
mailing list