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

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 7 03:05:23 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
----------------
kasuga-fj wrote:

I haven't tested it myself, but looking at the stack dump, the uninitialized variables seem suspicious. Anyway, they should be initialized to `nullptr`.
https://github.com/llvm/llvm-project/blob/4563cf607a25feabbaef6bb20076366437f01a2d/llvm/lib/Analysis/DependenceAnalysis.cpp#L825-L835

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


More information about the llvm-commits mailing list