Add a comment to clarify a future change
authorSanjoy Das <sanjoy@playingwithpointers.com>
Wed, 25 Oct 2017 21:40:59 +0000 (21:40 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Wed, 25 Oct 2017 21:40:59 +0000 (21:40 +0000)
llvm-svn: 316614

llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Analysis/ScalarEvolution.cpp

index 3190e7f..96309de 100644 (file)
@@ -1744,9 +1744,12 @@ private:
   /// Compute the maximum backedge count based on the range of values
   /// permitted by Start, End, and Stride. This is for loops of the form
   /// {Start, +, Stride} LT End.
+  ///
+  /// Precondition: the induction variable is known to be positive.  We *don't*
+  /// assert these preconditions so please be careful.
   const SCEV *computeMaxBECountForLT(const SCEV *Start, const SCEV *Stride,
-                                const SCEV *End, unsigned BitWidth,
-                                bool IsSigned);
+                                     const SCEV *End, unsigned BitWidth,
+                                     bool IsSigned);
 
   /// Verify if an linear IV with positive stride can overflow when in a
   /// less-than comparison, knowing the invariant term of the comparison,
index c69bd60..f6c45de 100644 (file)
@@ -9710,8 +9710,9 @@ const SCEV *ScalarEvolution::computeMaxBECountForLT(const SCEV *Start,
     StrideForMaxBECount =
         IsSigned ? getSignedRangeMin(Stride) : getUnsignedRangeMin(Stride);
   else
-    // Using a stride of 1 is safe when computing max backedge taken count for
-    // a loop with unknown stride.
+    // Using a stride of 1 is safe when computing max backedge taken count for a
+    // loop with unknown stride, since the precondition for this function is
+    // that it is positive.
     StrideForMaxBECount = APInt(BitWidth, 1, IsSigned);
 
   APInt MaxValue = IsSigned ? APInt::getSignedMaxValue(BitWidth)