summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2019-06-27 19:22:43 +0000
committerPhilip Reames <listmail@philipreames.com>2019-06-27 19:22:43 +0000
commit1cf9e72cbc019bd33771900f349d1fc651d682be (patch)
tree72d72cf92c6d67f025aed807c88a7688529ce2c3
parentbd34e50cf0a908c6fe36a5a327281fb292fb1cfc (diff)
downloadbcm5719-llvm-1cf9e72cbc019bd33771900f349d1fc651d682be.tar.gz
bcm5719-llvm-1cf9e72cbc019bd33771900f349d1fc651d682be.zip
Update -analyze -scalar-evolution output for multiple exit loops w/computable exit values
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. llvm-svn: 364579
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp24
-rw-r--r--llvm/test/Analysis/ScalarEvolution/trip-count14.ll4
2 files changed, 18 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 0a87a084644..a66e609e4ee 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -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 << ": ";
diff --git a/llvm/test/Analysis/ScalarEvolution/trip-count14.ll b/llvm/test/Analysis/ScalarEvolution/trip-count14.ll
index 15080613881..711939bc112 100644
--- a/llvm/test/Analysis/ScalarEvolution/trip-count14.ll
+++ b/llvm/test/Analysis/ScalarEvolution/trip-count14.ll
@@ -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:
OpenPOWER on IntegriCloud