[llvm-branch-commits] [llvm] [GVN] Support critical-edge splitting in loop-load PRE (PR #206694)
Antonio Frighetto via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 15 03:13:04 PDT 2026
================
@@ -2018,9 +2018,38 @@ bool GVNPass::performLoopLoadPRE(LoadInst *Load,
if (LoadPtr->canBeFreed())
return false;
- // TODO: Support critical edge splitting if blocker has more than 1 successor.
+ // The reload is inserted at the end of the chosen in-loop block so its value
+ // reaches the header along the path back to the latch. If that block has
+ // multiple successors, inserting there would also run the load on paths that
+ // leave the loop. Split the critical edge to the unique in-loop successor so
+ // the reload only runs on the path that feeds the header.
+ BasicBlock *InsertBlock = LoopBlock;
----------------
antoniofrighetto wrote:
Could we please clarify a bit the comment above by outlining that there is no critical edge to split when LoopBlock has an unconditional jump in the first place, the reload is added to the split critical edge, and we specifically look for blocks and the block about to be split has a known backedge (`InLoopSucc`)?
https://github.com/llvm/llvm-project/pull/206694
More information about the llvm-branch-commits
mailing list