[llvm] [JumpThreading] Use context when checking speculatability (PR #203912)

Nikolas Klauser via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 15 07:27:21 PDT 2026


================
@@ -1364,18 +1364,28 @@ bool JumpThreadingPass::simplifyPartiallyRedundantLoad(LoadInst *LoadI) {
   // farther than to a predecessor, we need to reuse the code from GVN's PRE.
   // It requires domination tree analysis, so for this simple case it is an
   // overkill.
-  if (PredsScanned.size() != AvailablePreds.size() &&
-      !isSafeToSpeculativelyExecute(LoadI))
-    for (auto I = LoadBB->begin(); &*I != LoadI; ++I)
-      if (!isGuaranteedToTransferExecutionToSuccessor(&*I))
-        return false;
+  std::optional<bool> GuaranteedToTransfer;
----------------
philnik777 wrote:

Can't we just have a `bool` that says whether we did the check already? If the result was `false` we'd have bailed, no?

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


More information about the llvm-commits mailing list