<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (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:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
-->
</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]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal>Hello,<o:p></o:p></p>
<p class=MsoNormal>I was trying to trace the Loop vectorizer of the LLVM, I
wrote a simple loop with a clear dependency. <o:p></o:p></p>
<p class=MsoNormal>But found that the debug shows that ‘we can vectorize this
loop’<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Here you are my loop with dependency:<o:p></o:p></p>
<p class=MsoNormal>for(int k=20;k<50;k++)<o:p></o:p></p>
<p class=MsoNormal> dataY[k] = dataY[k-1];<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>And the debug prints:<o:p></o:p></p>
<p class=MsoNormal>LV: Checking a loop in "main"<o:p></o:p></p>
<p class=MsoNormal>LV: Found a loop: for.body4<o:p></o:p></p>
<p class=MsoNormal>LV: Found an induction variable.<o:p></o:p></p>
<p class=MsoNormal>LV: Found a write-only loop!<o:p></o:p></p>
<p class=MsoNormal>LV: We can vectorize this loop!<o:p></o:p></p>
<p class=MsoNormal>...<o:p></o:p></p>
<p class=MsoNormal>LV: Vectorization is possible but not beneficial.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>From the LLVM IR, it contains only one ‘store’ instruction
with ‘%.pre’. Seems that no ‘load’ instruction prevented the Vectorizer to
detect dependency.<o:p></o:p></p>
<p class=MsoNormal>Is that a bug, or I’m missing something? Please advice<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>for.body4:
; preds = %for.body4, %for.cond2.preheader<o:p></o:p></p>
<p class=MsoNormal> %k.030 = phi i32 [ 20, %for.cond2.preheader ], [
%inc8, %for.body4 ]<o:p></o:p></p>
<p class=MsoNormal> %arrayidx6 = getelementptr inbounds i32* %0, i32
%k.030<o:p></o:p></p>
<p class=MsoNormal> store i32 %.pre, i32* %arrayidx6, align 4, !tbaa !0<o:p></o:p></p>
<p class=MsoNormal> %inc8 = add nsw i32 %k.030, 1<o:p></o:p></p>
<p class=MsoNormal> %exitcond32 = icmp eq i32 %inc8, 50<o:p></o:p></p>
<p class=MsoNormal> br i1 %exitcond32, label %for.cond10.preheader, label
%for.body4<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Thanks in advance,<o:p></o:p></p>
<p class=MsoNormal>Sara Elshobaky<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>