[llvm] [CodeGen] Ignore requiresStructuredCFG check in canSplitCriticalEdge if successor is loop header (PR #154063)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 25 07:00:41 PDT 2025
================
@@ -1403,7 +1403,14 @@ bool MachineBasicBlock::canSplitCriticalEdge(
const MachineFunction *MF = getParent();
// Performance might be harmed on HW that implements branching using exec mask
// where both sides of the branches are always executed.
- if (MF->getTarget().requiresStructuredCFG())
+ // However, if `Succ` is a loop header, splitting the critical edge will not
+ // break structured CFG.
+ bool SuccIsLoopHeader = false;
+ if (MLI) {
+ const MachineLoop *L = MLI->getLoopFor(Succ);
+ SuccIsLoopHeader = L && L->getHeader() == Succ;
+ }
+ if (MF->getTarget().requiresStructuredCFG() && !SuccIsLoopHeader)
return false;
----------------
arsenm wrote:
```suggestion
if (MF->getTarget().requiresStructuredCFG()) {
// If `Succ` is a loop header, splitting the critical edge will not
// break structured CFG.
if (MLI) {
const MachineLoop *L = MLI->getLoopFor(Succ);
return L && L->getHeader() == Succ;
}
return false;
}
```
https://github.com/llvm/llvm-project/pull/154063
More information about the llvm-commits
mailing list