[llvm] [SimplifyCFG] Hoist common code when succ is unreachable block (PR #165570)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 29 09:01:23 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())
+ continue;
+ // If Succ has >1 predecessors, continue to check if the Succ is terminated
----------------
nikic wrote:
terminated by an unreachable inst -> contains only an unreachable inst
https://github.com/llvm/llvm-project/pull/165570
More information about the llvm-commits
mailing list