[PATCH] D105535: [NFC] Remove duplicate function calls

Dmitry Makogon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 7 01:14:03 PDT 2021


dmakogon created this revision.
dmakogon added a reviewer: mkazantsev.
dmakogon added a project: LLVM.
Herald added a subscriber: hiraditya.
dmakogon requested review of this revision.
Herald added a subscriber: llvm-commits.

Removed repeated call of L->getHeader(). Now using previously stored return value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105535

Files:
  llvm/lib/Transforms/Scalar/LoopDeletion.cpp


Index: llvm/lib/Transforms/Scalar/LoopDeletion.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopDeletion.cpp
+++ llvm/lib/Transforms/Scalar/LoopDeletion.cpp
@@ -228,8 +228,8 @@
   SmallPtrSet<BasicBlock *, 4> LiveBlocks;
   // Edges that are reachable on the 1st iteration.
   DenseSet<BasicBlockEdge> LiveEdges;
-  LiveBlocks.insert(L->getHeader());
+  LiveBlocks.insert(Header);

   SmallPtrSet<BasicBlock *, 4> Visited;
   auto MarkLiveEdge = [&](BasicBlock *From, BasicBlock *To) {
     assert(LiveBlocks.count(From) && "Must be live!");
@@ -286,21 +286,21 @@
   //     iteration, mark this successor live.
   // 3b. If we cannot prove it, conservatively assume that all successors are
   //     live.
-  auto &DL = L->getHeader()->getModule()->getDataLayout();
+  auto &DL = Header->getModule()->getDataLayout();
   const SimplifyQuery SQ(DL);
   for (auto *BB : RPOT) {
     Visited.insert(BB);

     // This block is not reachable on the 1st iterations.
     if (!LiveBlocks.count(BB))
       continue;

     // Skip inner loops.
     if (LI.getLoopFor(BB) != L) {
       MarkAllSuccessorsLive(BB);
       continue;
     }

     // If Phi has only one input from all live input blocks, use it.
     for (auto &PN : BB->phis()) {
       if (!PN.getType()->isIntegerTy())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105535.356887.patch
Type: text/x-patch
Size: 1335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210707/5351f54f/attachment.bin>


More information about the llvm-commits mailing list