<div dir="ltr">Seems broken, I think r256338 fixes it.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 23, 2015 at 9:48 AM, Sanjoy Das via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: sanjoy<br>
Date: Wed Dec 23 11:48:14 2015<br>
New Revision: 256338<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=256338&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=256338&view=rev</a><br>
Log:<br>
[SCEV] Fix getLoopBackedgeTakenCounts<br>
<br>
The way `getLoopBackedgeTakenCounts` is written right now isn't<br>
correct. It will try to compute and store the BE counts of a Loop<br>
#{child loop} number of times (which may be zero).<br>
<br>
Modified:<br>
llvm/trunk/lib/Analysis/ScalarEvolution.cpp<br>
<br>
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=256338&r1=256337&r2=256338&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=256338&r1=256337&r2=256338&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Dec 23 11:48:14 2015<br>
@@ -9439,23 +9439,22 @@ static void replaceSubString(std::string<br>
/// getLoopBackedgeTakenCounts - Helper method for verifyAnalysis.<br>
static void<br>
getLoopBackedgeTakenCounts(Loop *L, VerifyMap &Map, ScalarEvolution &SE) {<br>
- for (Loop::reverse_iterator I = L->rbegin(), E = L->rend(); I != E; ++I) {<br>
- getLoopBackedgeTakenCounts(*I, Map, SE); // recurse.<br>
+ std::string &S = Map[L];<br>
+ if (S.empty()) {<br>
+ raw_string_ostream OS(S);<br>
+ SE.getBackedgeTakenCount(L)->print(OS);<br>
<br>
- std::string &S = Map[L];<br>
- if (S.empty()) {<br>
- raw_string_ostream OS(S);<br>
- SE.getBackedgeTakenCount(L)->print(OS);<br>
-<br>
- // false and 0 are semantically equivalent. This can happen in dead loops.<br>
- replaceSubString(OS.str(), "false", "0");<br>
- // Remove wrap flags, their use in SCEV is highly fragile.<br>
- // FIXME: Remove this when SCEV gets smarter about them.<br>
- replaceSubString(OS.str(), "<nw>", "");<br>
- replaceSubString(OS.str(), "<nsw>", "");<br>
- replaceSubString(OS.str(), "<nuw>", "");<br>
- }<br>
+ // false and 0 are semantically equivalent. This can happen in dead loops.<br>
+ replaceSubString(OS.str(), "false", "0");<br>
+ // Remove wrap flags, their use in SCEV is highly fragile.<br>
+ // FIXME: Remove this when SCEV gets smarter about them.<br>
+ replaceSubString(OS.str(), "<nw>", "");<br>
+ replaceSubString(OS.str(), "<nsw>", "");<br>
+ replaceSubString(OS.str(), "<nuw>", "");<br>
}<br>
+<br>
+ for (auto *L : reverse(*L))<br>
+ getLoopBackedgeTakenCounts(L, Map, SE); // recurse.<br>
}<br>
<br>
void ScalarEvolution::verify() const {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>