[Mlir-commits] [mlir] [mlir][scf] Clamp normalized loop sizes where they are combined (PR #223256)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Oct 5 18:55:32 PDT 2026
MaheshRavishankar wrote:
> > I see your point here, but can you explain a bit more where you are using 0, and where you are using 1?
>
> @MaheshRavishankar, both clamps apply to the same normalized size ceildiv(ub - lb, step), for two different uses: clamped at 0, it goes into the product that becomes the coalesced loop's UB. A negative size is an empty loop, and the prod being 0 makes the coalesced loop empty too (without this the two -ve sizes multiply into a positive trip count, which is the bug). Clamped at 1, it is used as the affine.delinearize_index basis in coalesceLoops and as the divsi/remsi divisor in collapseParallelLoops, where 0 would divide by zero and a negative value is not a legal basis. . Whenever the 1-clamp changes a value, the 0-clamp has already made the trip count 0, so the body never runs and the substituted divisor is never observed.
I am not sure how the uses of the value decides what value to clamp to....
https://github.com/llvm/llvm-project/pull/223256
More information about the Mlir-commits
mailing list