[llvm] [LoopFusion] Cleanup control flow before Fusion (PR #226289)

Congzhe Cao via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 08:08:39 PDT 2026


================
@@ -503,6 +586,11 @@ struct LoopFuser {
                       << "\n");
     bool Changed = false;
 
+    // Canonicalize the CFG around loop guards before looking for candidates,
+    // so that guarded loops are recognized as such and as adjacent.
+    for (Loop *L : LI.getLoopsInPreorder())
----------------
CongzheUalberta wrote:

Probably makes sense to move this code to within the `run()` function, i,e, put it together with the following code. Would be cleaner doing canonicalizations in one place.

```
for (auto &L : LI) {
    Changed |=
        simplifyLoop(L, &DT, &LI, &SE, &AC, nullptr, false /* PreserveLCSSA */);
  }
```

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


More information about the llvm-commits mailing list