[llvm] [DependenceAnalysis] Extending SIV to handle separate loops (PR #128782)

Alireza Torabian via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 24 09:32:57 PDT 2025


================
@@ -542,10 +619,23 @@ namespace llvm {
     ///     e - 5
     ///     f - 6
     ///     g - 7 = MaxLevels
-    void establishNestingLevels(const Instruction *Src,
-                                const Instruction *Dst);
-
-    unsigned CommonLevels, SrcLevels, MaxLevels;
+    /// SeparateLevels counts the number of levels after common levels that are
+    /// not common but are similar, meaning that they have the same tripcount
+    /// and depth. Assume that in this code fragment, levels c and e are
+    /// similar. In this case only the loop nests at the next level after
+    /// common levels are similar, and SeparateLevel is set to 1.
+    /// If there are similar loop nests, we could use the APIs with considering
+    /// them as fused loops. In that case the level numbers for the previous
+    /// code look like
+    ///     a   - 1
+    ///     b   - 2
+    ///     c,e - 3 = CommonLevels
+    ///     d   - 4 = SrcLevels
+    ///     f   - 5
+    ///     g   - 6 = MaxLevels
----------------
1997alireza wrote:

I renamed the variables form Separate to Fusable.
The comments I have added explains what FusableLevels means and how it is going to be used in the tests. We are not changing the levels in establishNestingLevels, but we change them in [depends function](https://github.com/1997alireza/llvm-project/commit/4cc82e90d43b2445f2f796d78c7cc82740e40e83#diff-2d5f1ae1260d47d458eaed38ae7d5d5e7d8782232c205b621355d07ee51fb084R3802) so the tests could be run on those levels as well.

https://github.com/llvm/llvm-project/pull/128782


More information about the llvm-commits mailing list