[llvm] [LoopFusion] Simplifying the legality checks (PR #171889)

Alireza Torabian via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 12 09:16:31 PST 2025


================
@@ -1497,11 +1404,14 @@ struct LoopFuser {
   /// FC1. If not, then the loops are not adjacent. If the two candidates are
   /// not guarded loops, then it checks whether the exit block of \p FC0 is the
   /// preheader of \p FC1.
-  bool isAdjacent(const FusionCandidate &FC0,
-                  const FusionCandidate &FC1) const {
+  /// Strictly means there is no predecessor for FC1 unless it is from FC0,
+  /// i.e., FC0 dominates FC1.
+  bool isStrictlyAdjacent(const FusionCandidate &FC0,
----------------
1997alireza wrote:

An exit block may have conditional branch in general and we don't need this assumption here. To check the adjacency, when the loops are not guarded, we check that exit block of the first loop is the preheader of the second. The only assumption is that if there is a linear chain of blocks in between, they have been simplified before running the loop fusion.

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


More information about the llvm-commits mailing list