[llvm] [DependenceAnalysis] Extending SIV to handle fusable loops (PR #128782)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 7 15:44:53 PDT 2025
amehsan wrote:
> What happens in a case like the following?
>
> ```c
> for (int i = 0; i <100; i++)
> for (int j = 0; j < 100; j++) {
> for (int k = 0; k < 10; k++)
> A[i][j][2*k] = 42;
> for (int k = 0; k < 10; k++)
> A[i][j][2*k + 1] = 43;
> }
> ```
>
> Currently DA returns `[0 0]` between the first store and the second one. However, once we fused the k-loops, SIV test will disprove the dependency and it would become `none` (godbolt: https://godbolt.org/z/4GT49nzdo).
>
> So, this may be an improvement in this case, but at the very least, the result has changed. In general, assuming loops to be fused can affect the outer common loops, though I'm not sure if that's actually problematic.
If my understanding is correct this won't be a problem. Because the patch essentially says: let's assume the inner most loops are fused and then check the dependences. Apart from that all logic of dep analysis is the existing logic. If there is a bug (meaning, a dependency that is not reported) the bug should be in the existing logic. We should be able to reproduce the bug by manually fusing the loops and then checking for dependencies again.
https://github.com/llvm/llvm-project/pull/128782
More information about the llvm-commits
mailing list