diff options
author | Florian Hahn <flo@fhahn.com> | 2023-07-04 21:28:02 +0100 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2023-07-04 21:28:03 +0100 |
commit | 1746ac42cae1dbe5fdef2af8e887a7e6015605ec (patch) | |
tree | 9e573640f3b9abc8722a55c71c58e430103a59b6 /llvm/lib | |
parent | b4b532a9562a1ebca347edc566363fba0531115b (diff) | |
download | llvm-1746ac42cae1dbe5fdef2af8e887a7e6015605ec.zip llvm-1746ac42cae1dbe5fdef2af8e887a7e6015605ec.tar.gz llvm-1746ac42cae1dbe5fdef2af8e887a7e6015605ec.tar.bz2 |
[LV] Forget SCEVs for exit phis after vectorization.
After vectorization, the exit blocks of the original loop will have additional
predecessors. Invalidate SCEVs for the exit phis in case SE looked through
single-entry phis.
Fixes https://github.com/llvm/llvm-project/issues/63368
Fixes https://github.com/llvm/llvm-project/issues/63669
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 8e299ac..d82c664 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -3715,6 +3715,15 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State, // Forget the original basic block. PSE.getSE()->forgetLoop(OrigLoop); + // After vectorization, the exit blocks of the original loop will have + // additional predecessors. Invalidate SCEVs for the exit phis in case SE + // looked through single-entry phis. + SmallVector<BasicBlock *> ExitBlocks; + OrigLoop->getExitBlocks(ExitBlocks); + for (BasicBlock *Exit : ExitBlocks) + for (PHINode &PN : Exit->phis()) + PSE.getSE()->forgetValue(&PN); + VPBasicBlock *LatchVPBB = Plan.getVectorLoopRegion()->getExitingBasicBlock(); Loop *VectorLoop = LI->getLoopFor(State.CFG.VPBB2IRBB[LatchVPBB]); if (Cost->requiresScalarEpilogue(VF.isVector())) { |