<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Florian has been working on loop peeling to remove control flow from loop bodies in <a href="https://reviews.llvm.org/D43876" class="OWAAutoLink">https://reviews.llvm.org/D43876</a>. For larger constants or other loop
 invariant bounds, such like:<span style="font-size: 12pt;"></span></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div><span style="font-family: "Courier New", monospace;">for (unsigned i = 0; i; i < 1000; ++i) {</span></div>
<div><span style="font-size: 12pt; font-family: "Courier New", monospace;">  if (i < M)</span><br>
</div>
<div><span style="font-family: "Courier New", monospace;">  ... something</span></div>
<div><span style="font-family: "Courier New", monospace;">  else</span></div>
<div><span style="font-family: "Courier New", monospace;">  ... something else</span></div>
<div><span style="font-family: "Courier New", monospace;">}</span></div>
<div><span style="font-family: "Courier New", monospace;"><br>
</span></div>
<div><span style="font-family: "Courier New", monospace;"><span style="font-family: Calibri, Helvetica, sans-serif;">The loop could be split into two, like so:</span><br>
</span></div>
<div><br>
</div>
<div><span style="font-family: "Courier New", monospace;">Min = min(1000, M);</span></div>
<div><span style="font-family: "Courier New", monospace;">unsigned i;</span></div>
<div><span style="font-family: "Courier New", monospace;">for (i = 0; i; i < Min; ++i) {</span></div>
<div><span style="font-family: "Courier New", monospace;">    ... something</span></div>
<div><span style="font-family: "Courier New", monospace;">}</span></div>
<div><br>
</div>
<div><span style="font-family: "Courier New", monospace;">for (; i; i < 1000; ++i) {</span></div>
<div><span style="font-family: "Courier New", monospace;">    ... something else</span></div>
<div><span style="font-family: "Courier New", monospace;">}</span></div>
<br>
<p></p>
<p style="margin-top:0;margin-bottom:0">Both loop distribute and versioning are designed to analyze memory and enable vectorization, but is there much preventing them from being able to split loops to remove control-flow instead? If this seems feasible, could
 someone give some advice on what would be needed?</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Thanks,</p>
<p style="margin-top:0;margin-bottom:0">sam</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p></p>
<p style="font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">Sam Parker</span></p>
<span style="font-family:Calibri,Helvetica,sans-serif"></span>
<p style="font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">Compilation Tools Engineer | Arm</span></p>
<span style="font-family:Calibri,Helvetica,sans-serif"></span>
<p style="font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">. . . . . . . . . . . . . . . . . . . . . . . . . . .</span></p>
<span style="font-family:Calibri,Helvetica,sans-serif"></span>
<p style="font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">Arm.com</span></p>
<p></p>
</div>
</div>
</div>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose,
 or store or copy the information in any medium. Thank you.
</body>
</html>