[llvm] [LoopInfo] Add recompute() and use it in SimpleLoopUnswitch (PR #213514)

Alexis Engelke via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 2 12:03:47 PDT 2026


================
@@ -854,6 +862,20 @@ template <class BlockT, class LoopT> class LoopInfoBase {
   void analyze(const DominatorTreeBase<BlockT, false> &DomTree);
   ///@}
 
+  /// Rebuild the loop forest from the CFG, reusing the existing loop object for
+  /// every block that still heads a loop. Analyses that key on loop pointers,
----------------
aengelke wrote:

> Analyses that key on loop pointers

They could also key on the loop header block (probably by block number) instead, which uniquely describes the loop. Maybe this makes things easier? Reusing Loop allocations just for this seems a bit hacky and would also simplify the implementation (in particular eliminating the alloc callback).

Could be a series of follow-up changes, though.

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


More information about the llvm-commits mailing list