Skip to content

Commit 82e48ee

Browse files
update getKnownTripCountBound function name and rename tripCount to minTripCount.
1 parent fa68fe1 commit 82e48ee

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,8 @@ void mlir::affine::getTripCountMapAndOperands(
216216

217217
/// Take the min if all trip counts are constant.
218218
static std::optional<uint64_t>
219-
getConstantTripCountFromAffineMap(AffineMap map,
220-
SmallVectorImpl<Value> &operands,
221-
presburger::BoundType type) {
219+
getKnownTripCountBound(AffineMap map, SmallVectorImpl<Value> &operands,
220+
presburger::BoundType type) {
222221
std::optional<uint64_t> tripCount;
223222
for (auto resultExpr : map.getResults()) {
224223
AffineMap subMap =
@@ -260,8 +259,7 @@ std::optional<uint64_t> mlir::affine::getConstantTripCount(AffineForOp forOp) {
260259

261260
if (!map)
262261
return std::nullopt;
263-
return getConstantTripCountFromAffineMap(map, operands,
264-
presburger::BoundType::LB);
262+
return getKnownTripCountBound(map, operands, presburger::BoundType::LB);
265263
}
266264

267265
/// Returns the maximum trip count when the operand of forOp has a range. If the
@@ -275,8 +273,7 @@ mlir::affine::getUpperBoundOnTripCount(AffineForOp forOp) {
275273

276274
if (!map)
277275
return std::nullopt;
278-
return getConstantTripCountFromAffineMap(map, operands,
279-
presburger::BoundType::UB);
276+
return getKnownTripCountBound(map, operands, presburger::BoundType::UB);
280277
}
281278

282279
/// Returns the greatest known integral divisor of the trip count. Affine

mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ static void replaceIterArgsAndYieldResults(AffineForOp forOp) {
116116
/// Promotes the loop body of a forOp to its containing block if the forOp
117117
/// was known to have a single iteration.
118118
LogicalResult mlir::affine::promoteIfSingleIteration(AffineForOp forOp) {
119-
std::optional<uint64_t> tripCount = getConstantTripCount(forOp);
119+
std::optional<uint64_t> minTripCount = getConstantTripCount(forOp);
120120
std::optional<uint64_t> maxTripCount = getUpperBoundOnTripCount(forOp);
121-
if (!tripCount || *tripCount != 1 || !maxTripCount || *maxTripCount != 1)
121+
if (!minTripCount || *minTripCount != 1 || !maxTripCount ||
122+
*maxTripCount != 1)
122123
return failure();
123124

124125
// TODO: extend this for arbitrary affine bounds.

0 commit comments

Comments
 (0)