[Mlir-commits] [mlir] [MLIR][Affine] Simplify affine.for bounds by pruning redundant expressions via ValueBoundsConstraintSet (PR #199032)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Fri May 22 00:51:57 PDT 2026
================
@@ -218,11 +218,105 @@ struct SimplifyDelinearizeOfLinearizeDisjoint final
}
};
+/// Simplifies the affine map results by eliminating redundant expressions.
+///
+/// This function performs a pairwise comparison of all expressions in the map
+/// using the analysis from `ValueBoundsConstraintSet`. If an expression `a` is
+/// statically proven to be strictly bounded or covered by another expression
+/// `b` (based on the given comparison operator `cmp`), `a` is considered
+/// redundant and is safely pruned from the results. NOTE: We iterate backwards
+/// (from size-1 down to 0) to safely erase elements from the `SmallVector`
+/// without causing iterator invalidation or indexing shifts for upcoming
+/// elements.
+static SmallVector<AffineExpr>
+simplifyRedundantMapResults(AffineMap map, SmallVector<Value> operands,
+ ValueBoundsConstraintSet::ComparisonOperator cmp) {
+ SmallVector<AffineExpr> mapResults(map.getResults());
+ auto *context = map.getContext();
----------------
ftynse wrote:
Almost always avoid auto. Acceptable uses are casts, constructors, iterators and lambdas.
https://github.com/llvm/llvm-project/pull/199032
More information about the Mlir-commits
mailing list