diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/contrib/llvm-project/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp index 597c88ad13df..1a9eaf242190 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp @@ -316,7 +316,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { L->dump()); return Rotated; } - if (*Metrics.NumInsts.getValue() > MaxHeaderSize) { + if (Metrics.NumInsts > MaxHeaderSize) { LLVM_DEBUG(dbgs() << "LoopRotation: NOT rotating - contains " << Metrics.NumInsts << " instructions, which is more than the threshold (" @@ -345,8 +345,14 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { // all outer loops because insertion and deletion of blocks that happens // during the rotation may violate invariants related to backedge taken // infos in them. - if (SE) + if (SE) { SE->forgetTopmostLoop(L); + // We may hoist some instructions out of loop. In case if they were cached + // as "loop variant" or "loop computable", these caches must be dropped. + // We also may fold basic blocks, so cached block dispositions also need + // to be dropped. + SE->forgetBlockAndLoopDispositions(); + } LLVM_DEBUG(dbgs() << "LoopRotation: rotating "; L->dump()); if (MSSAU && VerifyMemorySSA) @@ -713,7 +719,7 @@ static bool shouldSpeculateInstrs(BasicBlock::iterator Begin, if (!cast<GEPOperator>(I)->hasAllConstantIndices()) return false; // fall-thru to increment case - LLVM_FALLTHROUGH; + [[fallthrough]]; case Instruction::Add: case Instruction::Sub: case Instruction::And: @@ -789,6 +795,11 @@ bool LoopRotate::simplifyLoopLatch(Loop *L) { MergeBlockIntoPredecessor(Latch, &DTU, LI, MSSAU, nullptr, /*PredecessorWithTwoSuccessors=*/true); + if (SE) { + // Merging blocks may remove blocks reference in the block disposition cache. Clear the cache. + SE->forgetBlockAndLoopDispositions(); + } + if (MSSAU && VerifyMemorySSA) MSSAU->getMemorySSA()->verifyMemorySSA(); |