[llvm] [SimplifyCFG][SCCP] Preserve loop metadata when replacing terminators with branches (PR #220144)
Byeongjee Kang via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 1 13:55:21 PDT 2026
================
@@ -273,7 +268,11 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions,
// now.
if (TheOnlyDest) {
// Insert the new branch.
- Builder.CreateBr(TheOnlyDest);
+ UncondBrInst *NewBI = Builder.CreateBr(TheOnlyDest, SI);
+ // Preserve loop metadata when every switch destination is retained.
----------------
byeongjee wrote:
This is conservative, but going further would require extra loop analysis.
https://github.com/llvm/llvm-project/pull/220144
More information about the llvm-commits
mailing list