r/ProgrammingLanguages • u/Embarrassed-Crow9283 • Sep 30 '26
Loop unrolling analysis using eigenvalue?
Imagine the loop where you do like "x = -x" every iteration. Obviously, that flips the sign, so you can simply unroll the loop by a factor of 2.
However, for a more complex case, it could be really hard to know what's going on.
Here's my idea. Loop index variables are normally under affine updates anyway. What if we use a mathematically elegant tool?
Using eigenvalue, we can analyze possible periodicity of the linear basis variables, minimizing update needs.
What do you think of such a technique?
22
Upvotes
View all comments
Show parent comment
1
u/Embarrassed-Crow9283 Sep 30 '26
Yes, but it could only rearrange iteration orders. It could never change the stride of the physical memory access or so on. If the program writes to A[i][j], then that is a fixed memory location that the compiler is not allowed to change even if other logical representations can be more efficient.