Open AndraBisca opened 3 weeks ago
You can use this to compute the trip count of an scf.for
with static bounds and step: https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h#L175.
if (!forLoop.getSingleLowerBound() ||
!forLoop.getSingleUpperBound() || !forLoop.getSingleStep() ||
constantTripCount(*forLoop.getSingleLowerBound(),
*forLoop.getSingleUpperBound(),
*forLoop.getSingleStep())
.value_or(0) < unrollFactor)
forLoop.emitOpError()
<< "could not be unrolled because tripcount < unrollFactor: "
<< unrollFactor << "\n"
After #1545 designs with loops that have less iterations than the unroll factor fail silently.
It was caught by one of @eddierichter-amd designs.
The example here shows this error and expected output. The loop has 4 iterations and the unroll factor is 6.
@jtuyls