<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 5/10/2018 10:44 PM,
Gopalasubramanian, Ganesh via llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:DM5PR1201MB015544CE7636D82B7F931635829F0@DM5PR1201MB0155.namprd12.prod.outlook.com">
<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;}
@font-face
{font-family:"Calibri Light";
panose-1:2 15 3 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;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@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"><span style="font-family:"Calibri
Light",sans-serif">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri
Light",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri
Light",sans-serif">I am going through analysis on
unswitching + vectorization.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri
Light",sans-serif">For the below test, llvm unswitches
successfully but fails to vectorize the loop after
unswitching.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri
Light",sans-serif">Llvm bails out saying “Found an
outside user” apparently which is the value of ‘tmp’.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New"">int i, w, x[1000], y[1000],tmp;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New"">void fn()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New"">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New""> for (i = 0; i < 1000; i++) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New""> if (w==1) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New""> y[i] = 1; tmp = i*2;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New""> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New""> else if (w==2) {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New""> y[i] = 2; tmp = i*4;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New""> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New""> x[i] += y[i] + tmp;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New""> }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New"">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier
New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri
Light",sans-serif">GCC vectorizes the loop after
unswitching/if conversion. Request your help in vectorizing
this loop.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri
Light",sans-serif"><o:p> </o:p></span></p>
</div>
</blockquote>
<br>
Looks like some sort of pass ordering issue; it will vectorize if
indvars runs sometime between loop unswitch and the vectorizer.<br>
<br>
-Eli<br>
<br>
<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>