[llvm] [SCEV] Try to re-use existing LCSSA phis when expanding SCEVAddRecExpr. (PR #147214)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 7 13:51:33 PDT 2025


================
@@ -1223,6 +1223,24 @@ Value *SCEVExpander::expandAddRecExprLiterally(const SCEVAddRecExpr *S) {
   return Result;
 }
 
+Value *SCEVExpander::tryToReuseLCSSAPhi(const SCEVAddRecExpr *S) {
+  const Loop *L = S->getLoop();
+  BasicBlock *EB = L->getExitBlock();
----------------
fhahn wrote:

It should be possible to extend this to multi-exit loops, and just check for the exit dominating the insertion point as follow-up?

The main thing is that we need phis with single incoming values.

https://github.com/llvm/llvm-project/pull/147214


More information about the llvm-commits mailing list