[PATCH] D107773: LoopNest Analysis expansion to return instructions that prevent a Loop Nest from being perfect

Whitney Tsang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 9 11:17:39 PDT 2021


Whitney added inline comments.


================
Comment at: llvm/include/llvm/Analysis/LoopNestAnalysis.h:37
   LoopNest() = delete;
+  LoopNest &operator=(const LoopNest &) = delete;
 
----------------
Why is this needed?


================
Comment at: llvm/lib/Analysis/LoopNestAnalysis.cpp:53
 
+static CmpInst* getOuterLoopLatchCmp(const Loop &OuterLoop){
+
----------------
clang-format the lines you changed.


================
Comment at: llvm/lib/Analysis/LoopNestAnalysis.cpp:92
+      isSafeToSpeculativelyExecute(&I) || isa<PHINode>(I) || isa<BranchInst>(I);
+  if (!IsAllowed) {
+    return false;
----------------
no braces needed for single statement block,


================
Comment at: llvm/lib/Analysis/LoopNestAnalysis.cpp:107
                                   ScalarEvolution &SE) {
+  if (analyzeLoopNestForPerfectNest(OuterLoop,InnerLoop,SE) == PerfectLoopNest) {
+    return true;
----------------
return (analyzeLoopNestForPerfectNest(OuterLoop,InnerLoop,SE) == PerfectLoopNest);


================
Comment at: llvm/lib/Analysis/LoopNestAnalysis.cpp:152
     return llvm::all_of(BB, [&](const Instruction &I) {
-      bool isAllowed = isSafeToSpeculativelyExecute(&I) || isa<PHINode>(I) ||
-                       isa<BranchInst>(I);
-      if (!isAllowed) {
-        DEBUG_WITH_TYPE(VerboseDebug, {
-          dbgs() << "Instruction: " << I << "\nin basic block: " << BB
-                 << " is considered unsafe.\n";
-        });
-        return false;
-      }
-
-      // The only binary instruction allowed is the outer loop step instruction,
-      // the only comparison instructions allowed are the inner loop guard
-      // compare instruction and the outer loop latch compare instruction.
-      if ((isa<BinaryOperator>(I) && &I != &OuterLoopLB->getStepInst()) ||
-          (isa<CmpInst>(I) && &I != OuterLoopLatchCmp &&
-           &I != InnerLoopGuardCmp)) {
+      bool isSafeInstr = checkSafeInstruction(I, InnerLoopGuardCmp, OuterLoopLatchCmp, OuterLoopLB);
+      if (isSafeInstr){
----------------
Variable name starts with uppercase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107773



More information about the llvm-commits mailing list