[PATCH] D28460: getLoopEstimatedTripCount should really be called getLoopEstimatedBackedgeTakeCount.

Xin Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 12 21:10:14 PST 2017


trentxintong updated this revision to Diff 84220.
trentxintong added a comment.

Address suggestions by @mkuper


https://reviews.llvm.org/D28460

Files:
  lib/Transforms/Utils/LoopUtils.cpp


Index: lib/Transforms/Utils/LoopUtils.cpp
===================================================================
--- lib/Transforms/Utils/LoopUtils.cpp
+++ lib/Transforms/Utils/LoopUtils.cpp
@@ -1094,9 +1094,9 @@
     return 0;
 
   // Divide the count of the backedge by the count of the edge exiting the loop,
-  // rounding to nearest.
+  // rounding to nearest. Trip count == backedge-taken count + 1.
   if (LatchBR->getSuccessor(0) == L->getHeader())
-    return (TrueVal + (FalseVal / 2)) / FalseVal;
+    return (TrueVal + (FalseVal / 2)) / FalseVal + 1;
   else
-    return (FalseVal + (TrueVal / 2)) / TrueVal;
+    return (FalseVal + (TrueVal / 2)) / TrueVal + 1;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28460.84220.patch
Type: text/x-patch
Size: 675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170113/291131ee/attachment.bin>


More information about the llvm-commits mailing list