[llvm] [SimplifyCFG] Avoid threading for loop headers (PR #151142)
Arne Stenkrona via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 29 08:23:45 PDT 2025
================
@@ -8030,8 +8030,14 @@ bool SimplifyCFGOpt::simplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
// If this is a branch on something for which we know the constant value in
// predecessors (e.g. a phi node in the current block), thread control
// through this block.
- if (foldCondBranchOnValueKnownInPredecessor(BI, DTU, DL, Options.AC))
- return requestResimplify();
+ // Note: If BB is a loop header then there is a risk that threading introduces
+ // a non-canonical loop by moving a back edge. So we avoid this optimization
+ // for loop headers if NeedCanonicalLoop is set.
+ bool InHeader = !LoopHeaders.empty() && is_contained(LoopHeaders, BB);
----------------
ArneStenkrona2 wrote:
Noted. Removed.
https://github.com/llvm/llvm-project/pull/151142
More information about the llvm-commits
mailing list