[PATCH] D94717: [LoopNest] Consider loop nest with inner loop guard using outer loop induction variable to be perfect

Whitney Tsang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 4 13:50:46 PDT 2021


Whitney added a comment.

> As you can see for.end is not empty and so this loop's guard won't be detected!

>From looking at `skipEmptyBlockUntil`, `End` is **not** require to be empty, so `skipEmptyBlockUntil(for.end.loopexit, for.end)` would return `for.end`.



================
Comment at: llvm/lib/Analysis/LoopInfo.cpp:384-386
   BasicBlock *ExitFromLatchSucc = ExitFromLatch->getUniqueSuccessor();
   if (!ExitFromLatchSucc)
     return nullptr;
----------------
These 3 lines can be removed.


================
Comment at: llvm/lib/Analysis/LoopNestAnalysis.cpp:224
   const BasicBlock *BB = From->getUniqueSuccessor();
   const BasicBlock *PredBB = BB;
+  while (BB && BB != End && IsEmpty(BB) && !Visited.count(BB) &&
----------------
Should change this to `const BasicBlock *PredBB = From;`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94717/new/

https://reviews.llvm.org/D94717



More information about the llvm-commits mailing list