[llvm] [SimplifyCFG] Hoist common code when succ is unreachable block (PR #165570)
Kunqiu Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 29 07:04:25 PDT 2025
================
@@ -1866,10 +1866,19 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(Instruction *TI,
// If either of the blocks has it's address taken, then we can't do this fold,
// because the code we'd hoist would no longer run when we jump into the block
// by it's address.
- for (auto *Succ : successors(BB))
- if (Succ->hasAddressTaken() || !Succ->getSinglePredecessor())
+ for (auto *Succ : successors(BB)) {
+ if (Succ->hasAddressTaken())
return false;
-
+ if (Succ->getSinglePredecessor())
----------------
Camsyn wrote:
Moreover, should us relax this condition to support mutl-cases destination in `switch`?
```suggestion
if (Succ->getUniqPredecessor())
```
https://github.com/llvm/llvm-project/pull/165570
More information about the llvm-commits
mailing list