[Mlir-commits] [mlir] [mlir][affine][gpu] support unroll dynamic value and apply it to gpu.thread_id op (PR #128113)
lonely eagle
llvmlistbot at llvm.org
Tue Feb 25 03:21:08 PST 2025
================
@@ -884,15 +887,23 @@ void mlir::affine::getTileableBands(
/// Unrolls this loop completely.
LogicalResult mlir::affine::loopUnrollFull(AffineForOp forOp) {
std::optional<uint64_t> mayBeConstantTripCount = getConstantTripCount(forOp);
- if (mayBeConstantTripCount.has_value()) {
- uint64_t tripCount = *mayBeConstantTripCount;
- if (tripCount == 0)
- return success();
- if (tripCount == 1)
- return promoteIfSingleIteration(forOp);
- return loopUnrollByFactor(forOp, tripCount);
- }
- return failure();
+ std::optional<uint64_t> maxMayBeConstantTripCount =
+ getMaxConstantTripCount(forOp);
+
+ if (!mayBeConstantTripCount.has_value() &&
+ !maxMayBeConstantTripCount.has_value())
+ return failure();
+
+ uint64_t tripCount = *mayBeConstantTripCount;
+ uint64_t maxTripCount = *maxMayBeConstantTripCount;
+
+ // Trip equals 0, this loop cannot unroll.
+ if (tripCount <= 0)
+ return success();
+
+ if (tripCount == 1 && maxTripCount == 1)
----------------
linuxlonelyeagle wrote:
If it can run it will definitely be a huge improvement, it's really exciting.
https://github.com/llvm/llvm-project/pull/128113
More information about the Mlir-commits
mailing list