[clang] [llvm] [SimplifyCFG] Extend jump-threading to allow live local defs (PR #135079)

Yingwei Zheng via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 20 01:21:55 PDT 2025


================
@@ -3540,18 +3568,29 @@ foldCondBranchOnValueKnownInPredecessorImpl(BranchInst *BI, DomTreeUpdater *DTU,
     return false;
 
   // Now we know that this block has multiple preds and two succs.
-  // Check that the block is small enough and values defined in the block are
-  // not used outside of it.
-  if (!blockIsSimpleEnoughToThreadThrough(BB))
+  // Check that the block is small enough and record which non-local blocks use
+  // values defined in the block.
+
+  BlocksSet NonLocalUseBlocks;
+  BlocksSet ReachesNonLocalUseBlocks;
+  if (!blockIsSimpleEnoughToThreadThrough(BB, NonLocalUseBlocks))
+    return false;
+
+  if (NonLocalUseBlocks.contains(BI->getSuccessor(0)) &&
----------------
dtcxzyw wrote:

Is this a heuristic to check if the non-local uses live in both successors?
Can you add more comments for this check?

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


More information about the cfe-commits mailing list