[llvm] [FixIrreducible][UnifyLoopExits] Support switch statements (PR #206567)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 2 04:32:40 PDT 2026
================
@@ -309,20 +309,23 @@ static bool fixIrreducible(Cycle &C, CycleInfo &CI, DominatorTree &DT,
<< " -> " << printBasicBlock(Succ0)
<< (Succ0 && Succ1 ? " " : "") << printBasicBlock(Succ1)
<< '\n');
- } else if (CallBrInst *CallBr = dyn_cast<CallBrInst>(P->getTerminator())) {
- for (unsigned I = 0; I < CallBr->getNumSuccessors(); ++I) {
- BasicBlock *Succ = CallBr->getSuccessor(I);
+ } else if (isa<CallBrInst>(P->getTerminator()) ||
+ isa<SwitchInst>(P->getTerminator())) {
+ Instruction *Term = P->getTerminator();
+ for (unsigned I = 0; I < Term->getNumSuccessors(); ++I) {
+ BasicBlock *Succ = Term->getSuccessor(I);
if (Succ != Header)
continue;
- BasicBlock *NewSucc = SplitCallBrEdge(P, Succ, I, &DTU, &CI, LI);
+ BasicBlock *NewSucc = SplitMultiBrEdge(P, Succ, I, &DTU, &CI, LI);
CHub.addBranch(NewSucc, Succ);
----------------
hertelukas wrote:
I already started looking into it and can take care of it. I’ll probably be able to get a PR ready over the weekend. I agree that this should be fixed before we move forward with this PR.
Once the fix lands upstream, should I rebase this PR on top of the updated main branch, or is merging main into this branch also okay?
https://github.com/llvm/llvm-project/pull/206567
More information about the llvm-commits
mailing list