<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 6/30/2017 7:48 AM, Balaram Makam via
llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:00ad01d2f1af$ff64c290$fe2e47b0$@codeaurora.org">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Edit. Predecessor -> successor.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> llvm-dev
[<a class="moz-txt-link-freetext" href="mailto:llvm-dev-bounces@lists.llvm.org">mailto:llvm-dev-bounces@lists.llvm.org</a>] <b>On Behalf Of
</b>Balaram Makam via llvm-dev<br>
<b>Sent:</b> Friday, June 30, 2017 10:47 AM<br>
<b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> [llvm-dev] LoopSimplify pass prevents loop
unrolling<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi All,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">In the attached test case there, is an
unnested loop with 2 iterations. The loop latch block is
terminated by an unconditional branch, so simplifycfg folds
the almost empty latch block into its <b>successor</b> which
is the loop header. This results in an additional backedge in
the CFG, so when LoopRotate pass is called it canonicalizes
the loop into a nested loop. However, now the loop trip count
is unpredictable as the BackedgeTakenCount for the outer loop
is not loop invariant. As a result the loop cannot be
unrolled. Is this the intended canonicalization for this loop
or is the loopsimplify canonicalizing incorrectly? Should
simplifycfg skip folding the latch block into the loop header
if this results in additional backedges and let the empty
blocks be folded during CGP? More details in <a
href="https://bugs.llvm.org/show_bug.cgi?id=33605"
moz-do-not-send="true">https://bugs.llvm.org/show_bug.cgi?id=33605</a>.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</blockquote>
<br>
We have code that's supposed to prevent this from happening; see
<a class="moz-txt-link-freetext" href="https://reviews.llvm.org/rL264697">https://reviews.llvm.org/rL264697</a> . Maybe it also needs to check
whether the destination of the branch is a loop header?<br>
<br>
-Eli
<pre class="moz-signature" cols="72">--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
</body>
</html>