[Mlir-commits] [mlir] [mlir][affine] Use value bound inference to determine minimum/maximum trip counts in loop analysis (PR #128113)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Tue Apr 8 09:18:58 PDT 2025
================
@@ -212,6 +214,40 @@ void mlir::affine::getTripCountMapAndOperands(
tripCountValueMap.getOperands().end());
}
+/// Take the min if all trip counts are constant.
+static std::optional<uint64_t>
+getKnownTripCountBound(AffineMap map, SmallVectorImpl<Value> &operands,
+ presburger::BoundType type) {
+ std::optional<uint64_t> tripCount;
+ for (auto resultExpr : map.getResults()) {
+ AffineMap subMap =
+ AffineMap::get(map.getNumDims(), map.getNumSymbols(), resultExpr);
+ ValueBoundsConstraintSet::Variable var(subMap, operands);
+ auto lbBound = ValueBoundsConstraintSet::computeConstantBound(
+ mlir::presburger::BoundType::LB, var);
+ auto ubBound = ValueBoundsConstraintSet::computeConstantBound(
+ mlir::presburger::BoundType::UB, var, nullptr, true);
----------------
ftynse wrote:
Nit: please use the `/*argumentName=*/true` style for literals in function arguments for readability.
https://github.com/llvm/llvm-project/pull/128113
More information about the Mlir-commits
mailing list