[llvm] [DependenceAnalysis] Extending SIV to handle fusable loops (PR #128782)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 16 08:51:50 PDT 2025
amehsan wrote:
> (Sorry to bother you with my nitpicky comments.)
>
> Let me clarify my point, using the same example.
>
> ```c
> for (int i = 0; i < M; i++) {
> if (i < 10)
> for (int j = 0; j < N; j++)
> A[i+10][j] = 42;
> for (int j = 0; j < N; j++)
> A[i][j] = 43;
> }
> ```
>
> Your argument seems correct if we are analyzing the C language (or other high-level languages). But our target is LLVM IR which does not have explicit loop constructs such as `for` or `while` statements. Thus, loop-releated information (e.g., backedge-taken count) must be inferred in some way. Loop guards can be utilized for this purpose, for instance, a predicate like `N > 0` may be used to compute the backedge-taken count of the loop. From this perspective, I think it can be said that DA makes use of loop guards. The condition `i < 10` in the above example would also be treated as a loop guard. I think they are both equally loop guards and it should be impossible to distinguish information related to backedge-taken count from any other information. Therefore it's safer to think that DA might be indirectly using `i < 10` (although I don't know if that condition actually provides useful information).
>
What is relevant to DA is starting value and final value of induction variable. And the patch makes sure that those values satisfy certain conditions. That is enough to ensure correctness of the results.
https://github.com/llvm/llvm-project/pull/128782
More information about the llvm-commits
mailing list