Skip to content

Commit 23216b4

Browse files
[mlir][SCF][NFC] Remove duplicate getConstantTripCount implementation (#146347)
1 parent d805707 commit 23216b4

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

mlir/lib/Dialect/SCF/Utils/Utils.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -301,19 +301,8 @@ static Value ceilDivPositive(OpBuilder &builder, Location loc, Value dividend,
301301
/// constants, or optional otherwise. Trip count is computed as
302302
/// ceilDiv(highBound - lowBound, step).
303303
static std::optional<int64_t> getConstantTripCount(scf::ForOp forOp) {
304-
std::optional<int64_t> lbCstOp = getConstantIntValue(forOp.getLowerBound());
305-
std::optional<int64_t> ubCstOp = getConstantIntValue(forOp.getUpperBound());
306-
std::optional<int64_t> stepCstOp = getConstantIntValue(forOp.getStep());
307-
if (!lbCstOp.has_value() || !ubCstOp.has_value() || !stepCstOp.has_value())
308-
return {};
309-
310-
// Constant loop bounds computation.
311-
int64_t lbCst = lbCstOp.value();
312-
int64_t ubCst = ubCstOp.value();
313-
int64_t stepCst = stepCstOp.value();
314-
assert(lbCst >= 0 && ubCst >= 0 && stepCst > 0 &&
315-
"expected positive loop bounds and step");
316-
return llvm::divideCeilSigned(ubCst - lbCst, stepCst);
304+
return constantTripCount(forOp.getLowerBound(), forOp.getUpperBound(),
305+
forOp.getStep());
317306
}
318307

319308
/// Generates unrolled copies of scf::ForOp 'loopBodyBlock', with

0 commit comments

Comments
 (0)