[Mlir-commits] [mlir] [MLIR][Presburger] Implement IntegerRelation::mergeAndAlignSymbols (PR #76736)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Jan 5 05:40:53 PST 2024
================
@@ -1288,6 +1288,38 @@ void IntegerRelation::eliminateRedundantLocalVar(unsigned posA, unsigned posB) {
removeVar(posB);
}
+/// First merge and align identifiers into `other` from `this`. If an identifier
+/// exists in `other`, then align it; otherwise insert it assuming it is a new
+/// identifier. Then add identifiers that are in `other`, but not in `this` to
+/// `this`.
+void IntegerRelation::mergeAndAlignSymbols(IntegerRelation &other) {
+ assert(space.isUsingIds() && other.space.isUsingIds() &&
+ "Both relations need to have identifers to merge and align");
+
+ unsigned i = 0;
+ for (const Identifier identifier : space.getIds(VarKind::Symbol)) {
+ // Search in `other` starting at position `i` since the left of `i` is
+ // aligned.
+ auto *findBegin = other.space.getIds(VarKind::Symbol).begin() + i;
+ auto *findEnd = other.space.getIds(VarKind::Symbol).end();
+ auto *itr = std::find(findBegin, findEnd, identifier);
----------------
Abhinav271828 wrote:
if the type name is not too large, it may help to write it explicitly?
https://github.com/llvm/llvm-project/pull/76736
More information about the Mlir-commits
mailing list