From f15a8616011bfb1e34ade994350065127a7aea85 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Wed, 25 Oct 2017 21:40:59 +0000 Subject: [PATCH] Add a comment to clarify a future change llvm-svn: 316614 --- llvm/include/llvm/Analysis/ScalarEvolution.h | 7 +++++-- llvm/lib/Analysis/ScalarEvolution.cpp | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index 3190e7f..96309de 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -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, diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index c69bd60..f6c45de9 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -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) -- 2.7.4