[Mlir-commits] [mlir] [mlir][scf] Fix trip count signedness and overflow in SCF Utils (PR #178782)

Matthias Springer llvmlistbot at llvm.org
Fri Jan 30 09:30:31 PST 2026


================
@@ -251,8 +251,7 @@ FailureOr<scf::ParallelOp> parallelLoopUnrollByFactors(
 /// Get constant trip counts for each of the induction variables of the given
 /// loop operation. If any of the loop's trip counts is not constant, return an
 /// empty vector.
-/// TODO(#178506): Should return SmallVector<uint64_t> for correct signedness.
-llvm::SmallVector<int64_t>
+llvm::SmallVector<uint64_t>
----------------
matthias-springer wrote:

> however at this point we could ask if 64 bits is enough or is it valid to have larger numbers using i128 for example?

`scf.for` supports arbitrary integer types, so I'd say 64 bits are not generally enough.

I checked the implementation and all uses of this function here (`getConstLoopTripCounts`) within MLIR (there is only 1 call site). I think we should change the return type to `llvm::SmallVector<APInt>`. It's a small change.



https://github.com/llvm/llvm-project/pull/178782


More information about the Mlir-commits mailing list