[llvm] [LoopSafety] Cache whether block is guaranteed to execute (NFC) (PR #217943)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 00:36:50 PDT 2026


================
@@ -204,6 +204,14 @@ bool LoopSafetyInfo::allLoopPathsLeadToBlock(const Loop *CurLoop,
   if (BB == CurLoop->getHeader())
     return true;
 
+  auto [It, Inserted] = GuaranteedToExecute.try_emplace(BB, false);
+  if (Inserted)
+    It->second = allLoopPathsLeadToBlockImpl(CurLoop, BB, DT);
----------------
nikic wrote:

Yeah, that would probably make sense for LICMs use case. Though there are other users that use LoopSafetyInfo to perform a single isGuaranteedToExecute() query...

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


More information about the llvm-commits mailing list