Loop unrolling on LinAlg

I notice loop unrolling is not a transformation in the key transformations in LinAlg’s rationale document and would like to have a better understanding of its reason. Is unrolling expected to happen at a lower abstraction level than LinAlg or something else? I probably missed some document talking about this. Any pointer to an existing document or video talking about its reasoning is appreciated if it has already been discussed. Thanks.

Exactly, atm we can do unrolling directly on loops (scf.for, affine.for) and at the vector level (look for this pattern: llvm-project/VectorRewritePatterns.h at main · llvm/llvm-project · GitHub).

The loop unroll does what you’d expect; the vector level can unroll multiple dimensions, so it’s closer to an unroll-and-jam in traditional compiler parlance.

Caveat: vector unrolling patterns are a bit harder to use/control than we’d like atm, improvements most welcome :slight_smile:

1 Like

Thanks for the information @nicolasvasilache! I have one follow up question on having unroll(-and-jam) on loops and vector. This seems suggesting CodegenStrategy in LinAlg won’t be able to schedule unroll(-and-jam) atm. What I’m trying to better understand is what loop transformations is envisioned for CodegenStrategy within LinAlg. Are there loop transformations other than the ones in the rational document envisioned in the long term? Thanks.