[llvm-branch-commits] [llvm-branch] r258869 - Merging r258184:
Sanjoy Das via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 26 14:32:58 PST 2016
Author: sanjoy
Date: Tue Jan 26 16:29:46 2016
New Revision: 258869
URL: http://llvm.org/viewvc/llvm-project?rev=258869&view=rev
Log:
Merging r258184:
------------------------------------------------------------------------
r258184 | sanjoy | 2016-01-19 12:53:51 -0800 (Tue, 19 Jan 2016) | 20 lines
[SCEV] Fix PR26207
In some cases, the max backedge taken count can be more conservative
than the exact backedge taken count (for instance, because
ScalarEvolution::getRange is not control-flow sensitive whereas
computeExitLimitFromICmp can be). In these cases,
computeExitLimitFromCond (specifically the bit that deals with `and` and
`or` instructions) can create an ExitLimit instance with a
`SCEVCouldNotCompute` max backedge count expression, but a computable
exact backedge count expression. This violates an implicit SCEV
assumption: a computable exact BE count should imply a computable max BE
count.
This change
- Makes the above implicit invariant explicit by adding an assert to
ExitLimit's constructor
- Changes `computeExitLimitFromCond` to be more robust around
conservative max backedge counts
------------------------------------------------------------------------
Added:
llvm/branches/release_38/test/Transforms/IndVarSimplify/pr26207.ll
- copied unchanged from r258184, llvm/trunk/test/Transforms/IndVarSimplify/pr26207.ll
Modified:
llvm/branches/release_38/ (props changed)
llvm/branches/release_38/include/llvm/Analysis/ScalarEvolution.h
llvm/branches/release_38/lib/Analysis/ScalarEvolution.cpp
Propchange: llvm/branches/release_38/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 26 16:29:46 2016
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257886,257902,257905,257925,257929-257930,257940,257942,257977,257979,257997,258168,258207,258221,258273,258325,258406,258416,258428,258436,258690,258729
+/llvm/trunk:155241,257645,257648,257730,257775,257791,257875,257886,257902,257905,257925,257929-257930,257940,257942,257977,257979,257997,258168,258184,258207,258221,258273,258325,258406,258416,258428,258436,258690,258729
Modified: llvm/branches/release_38/include/llvm/Analysis/ScalarEvolution.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/include/llvm/Analysis/ScalarEvolution.h?rev=258869&r1=258868&r2=258869&view=diff
==============================================================================
--- llvm/branches/release_38/include/llvm/Analysis/ScalarEvolution.h (original)
+++ llvm/branches/release_38/include/llvm/Analysis/ScalarEvolution.h Tue Jan 26 16:29:46 2016
@@ -412,7 +412,11 @@ namespace llvm {
/*implicit*/ ExitLimit(const SCEV *E) : Exact(E), Max(E) {}
- ExitLimit(const SCEV *E, const SCEV *M) : Exact(E), Max(M) {}
+ ExitLimit(const SCEV *E, const SCEV *M) : Exact(E), Max(M) {
+ assert((isa<SCEVCouldNotCompute>(Exact) ||
+ !isa<SCEVCouldNotCompute>(Max)) &&
+ "Exact is not allowed to be less precise than Max");
+ }
/// Test whether this ExitLimit contains any computed information, or
/// whether it's all SCEVCouldNotCompute values.
Modified: llvm/branches/release_38/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/lib/Analysis/ScalarEvolution.cpp?rev=258869&r1=258868&r2=258869&view=diff
==============================================================================
--- llvm/branches/release_38/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/branches/release_38/lib/Analysis/ScalarEvolution.cpp Tue Jan 26 16:29:46 2016
@@ -5368,6 +5368,14 @@ ScalarEvolution::computeExitLimitFromCon
BECount = EL0.Exact;
}
+ // There are cases (e.g. PR26207) where computeExitLimitFromCond is able
+ // to be more aggressive when computing BECount than when computing
+ // MaxBECount. In these cases it is possible for EL0.Exact and EL1.Exact
+ // to match, but for EL0.Max and EL1.Max to not.
+ if (isa<SCEVCouldNotCompute>(MaxBECount) &&
+ !isa<SCEVCouldNotCompute>(BECount))
+ MaxBECount = BECount;
+
return ExitLimit(BECount, MaxBECount);
}
if (BO->getOpcode() == Instruction::Or) {
More information about the llvm-branch-commits
mailing list