[llvm] [polly] [SimpleLoopUnswitch] Generalize the notion of trivial unswitching (PR #193989)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 09:24:42 PDT 2026


================
@@ -591,6 +592,48 @@ static bool unswitchTrivialBranch(Loop &L, CondBrInst &BI, DominatorTree &DT,
     }
   }
 
+  std::optional<int> LatchIdx = std::nullopt;
+  if (FullUnswitch && L.getUniqueLatchExitBlock() != nullptr)
+    if (BI.getSuccessor(0) == L.getLoopLatch() &&
----------------
nikic wrote:

`BasicBlock *Latch = L.getLoopLatch()`. You're using it a lot, and it's not free.

Same for getUniqueLatchExitBlock.

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


More information about the llvm-commits mailing list