diff options
author | Nikita Popov <npopov@redhat.com> | 2024-02-07 11:06:51 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2024-02-07 11:27:26 +0100 |
commit | bec7181d5b9d1828129d78d440fd9e02d5cb63e8 (patch) | |
tree | 4d2f4bf6d5012d593306029159b7f4fd1297731b /llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | |
parent | e60c4b61f8bab25a137a481e4d2d3dbfa656807b (diff) | |
download | llvm-bec7181d5b9d1828129d78d440fd9e02d5cb63e8.zip llvm-bec7181d5b9d1828129d78d440fd9e02d5cb63e8.tar.gz llvm-bec7181d5b9d1828129d78d440fd9e02d5cb63e8.tar.bz2 |
[SCEVExpander] Don't use recursive expansion for ptr IV inc
Similar to the non-ptr case, directly create the getelementptr
instruction. Going through expandAddToGEP() no longer makes sense
with opaque pointers, where generating the necessary instruction
is trivial.
This avoids recursive expansion of (the SCEV of) StepV while the
IR is in an inconsistent state, in particular with an incomplete
IV phi node, which utilities may not be prepared to deal with.
Fixes https://github.com/llvm/llvm-project/issues/80954.
Diffstat (limited to 'llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp index 58dbac0..3a28909 100644 --- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp @@ -795,7 +795,8 @@ Value *SCEVExpander::expandIVInc(PHINode *PN, Value *StepV, const Loop *L, Value *IncV; // If the PHI is a pointer, use a GEP, otherwise use an add or sub. if (PN->getType()->isPointerTy()) { - IncV = expandAddToGEP(SE.getSCEV(StepV), PN); + // TODO: Change name to IVName.iv.next. + IncV = Builder.CreatePtrAdd(PN, StepV, "scevgep"); } else { IncV = useSubtract ? Builder.CreateSub(PN, StepV, Twine(IVName) + ".iv.next") : |