Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mlir/include/mlir/Dialect/Affine/IR/AffineValueMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ class AffineValueMap {
/// and/or operands have been modified.
LogicalResult canonicalize();

/// Checks if the application of this map to its operands is semantically
/// equal to `other`'s.
bool operator==(const AffineValueMap &other) const;
bool operator!=(const AffineValueMap &other) const {
return !(*this == other);
}

private:
// A mutable affine map.
MutableAffineMap map;
Expand Down
4 changes: 1 addition & 3 deletions mlir/lib/Dialect/Affine/Analysis/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2001,9 +2001,7 @@ bool MemRefAccess::operator==(const MemRefAccess &rhs) const {
AffineValueMap diff, thisMap, rhsMap;
getAccessMap(&thisMap);
rhs.getAccessMap(&rhsMap);
AffineValueMap::difference(thisMap, rhsMap, &diff);
return llvm::all_of(diff.getAffineMap().getResults(),
[](AffineExpr e) { return e == 0; });
return thisMap == rhsMap;
}

void mlir::affine::getAffineIVs(Operation &op, SmallVectorImpl<Value> &ivs) {
Expand Down
8 changes: 8 additions & 0 deletions mlir/lib/Dialect/Affine/IR/AffineValueMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,12 @@ ArrayRef<Value> AffineValueMap::getOperands() const {

AffineMap AffineValueMap::getAffineMap() const { return map.getAffineMap(); }

bool AffineValueMap::operator==(const AffineValueMap &other) const {
AffineValueMap diff;
AffineValueMap::difference(*this, other, &diff);
return llvm::all_of(diff.getAffineMap().getResults(), [](AffineExpr e) {
return e == getAffineConstantExpr(0, e.getContext());
});
}

AffineValueMap::~AffineValueMap() = default;