aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2025-07-28 16:24:46 +0100
committerFlorian Hahn <flo@fhahn.com>2025-07-28 16:24:46 +0100
commitf9f68af4b8d5f8dd0bf8f14174b8b223fcf54c97 (patch)
tree61360b557d5f47a031a4e0d750ba21cf23f0e8f1 /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
parent4d259de2ae88fb022acc722dedd60260a870eb8b (diff)
downloadllvm-f9f68af4b8d5f8dd0bf8f14174b8b223fcf54c97.zip
llvm-f9f68af4b8d5f8dd0bf8f14174b8b223fcf54c97.tar.gz
llvm-f9f68af4b8d5f8dd0bf8f14174b8b223fcf54c97.tar.bz2
[SCEV] Make sure LCSSA is preserved when re-using phi if needed.
If we insert a new add instruction, it may introduce a new use outside the loop that contains the phi node we re-use. Use fixupLCSSAFormFor to fix LCSSA form, if needed. This fixes a crash reported in https://github.com/llvm/llvm-project/pull/147824#issuecomment-3124670997.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index ddb062b..571fa11 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -1257,7 +1257,7 @@ Value *SCEVExpander::tryToReuseLCSSAPhi(const SCEVAddRecExpr *S) {
assert(Diff->getType()->isIntegerTy() &&
"difference must be of integer type");
Value *DiffV = expand(Diff);
- Value *BaseV = &PN;
+ Value *BaseV = fixupLCSSAFormFor(&PN);
if (PhiTy->isPointerTy()) {
if (STy->isPointerTy())
return Builder.CreatePtrAdd(BaseV, DiffV);