]> granicus.if.org Git - llvm/commitdiff
Update -analyze -scalar-evolution output for multiple exit loops w/computable exit...
authorPhilip Reames <listmail@philipreames.com>
Thu, 27 Jun 2019 19:22:43 +0000 (19:22 +0000)
committerPhilip Reames <listmail@philipreames.com>
Thu, 27 Jun 2019 19:22:43 +0000 (19:22 +0000)
The previous output was next to useless if *any* exit was not computable.  If we have more than one exit, show the exit count for each so that it's easier to see what's going from with SCEV analysis when debugging.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364579 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/trip-count14.ll

index 0a87a084644b0a7ad58356e20ae48b9717415109..a66e609e4eed2bacbca6d3cc40542d5215190a58 100644 (file)
@@ -11417,19 +11417,23 @@ static void PrintLoopInfo(raw_ostream &OS, ScalarEvolution *SE,
   L->getHeader()->printAsOperand(OS, /*PrintType=*/false);
   OS << ": ";
 
-  SmallVector<BasicBlock *, 8> ExitBlocks;
-  L->getExitBlocks(ExitBlocks);
-  if (ExitBlocks.size() != 1)
+  SmallVector<BasicBlock *, 8> ExitingBlocks;
+  L->getExitingBlocks(ExitingBlocks);
+  if (ExitingBlocks.size() != 1)
     OS << "<multiple exits> ";
 
-  if (SE->hasLoopInvariantBackedgeTakenCount(L)) {
-    OS << "backedge-taken count is " << *SE->getBackedgeTakenCount(L);
-  } else {
-    OS << "Unpredictable backedge-taken count. ";
-  }
+  if (SE->hasLoopInvariantBackedgeTakenCount(L))
+    OS << "backedge-taken count is " << *SE->getBackedgeTakenCount(L) << "\n";
+  else
+    OS << "Unpredictable backedge-taken count.\n";
 
-  OS << "\n"
-        "Loop ";
+  if (ExitingBlocks.size() > 1)
+    for (BasicBlock *ExitingBlock : ExitingBlocks) {
+      OS << "  exit count for " << ExitingBlock->getName() << ": "
+         << *SE->getExitCount(L, ExitingBlock) << "\n";
+    }
+
+  OS << "Loop ";
   L->getHeader()->printAsOperand(OS, /*PrintType=*/false);
   OS << ": ";
 
index 150806138817474276a71bdd263e73317ecf700b..711939bc112e273e00adf522f27ae50f622780ba 100644 (file)
@@ -82,6 +82,8 @@ if.end:
 
 ; CHECK-LABEL: Determining loop execution counts for: @s32_max2_unpredictable_exit
 ; CHECK-NEXT: Loop %do.body: <multiple exits> backedge-taken count is (((-1 * %n) + ((2 + %n) smax %n)) umin ((-1 * %n) + %x))
+; CHECK-NEXT:   exit count for do.body: ((-1 * %n) + %x)
+; CHECK-NEXT:   exit count for if.end: ((-1 * %n) + ((2 + %n) smax %n))
 ; CHECK-NEXT: Loop %do.body: max backedge-taken count is 2{{$}}
 
 do.end:
@@ -170,6 +172,8 @@ if.end:
 
 ; CHECK-LABEL: Determining loop execution counts for: @u32_max2_unpredictable_exit
 ; CHECK-NEXT: Loop %do.body: <multiple exits> backedge-taken count is (((-1 * %n) + ((2 + %n) umax %n)) umin ((-1 * %n) + %x))
+; CHECK-NEXT:   exit count for do.body: ((-1 * %n) + %x)
+; CHECK-NEXT:   exit count for if.end: ((-1 * %n) + ((2 + %n) umax %n))
 ; CHECK-NEXT: Loop %do.body: max backedge-taken count is 2{{$}}
 
 do.end: