<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Apr 12, 2018, 8:40 AM Benoit Meister <<a href="mailto:meister@reservoir.com">meister@reservoir.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thank you, Ayal! And thanks for the quote, Mehdi. I believe it says that it would be a normal thing for the Loop Vectorizer to conform to the backend's preferred alignment constraints as given by the datalayout.<br><br><div class="gmail_quote"><div dir="ltr">On Thu, Apr 12, 2018, 3:24 AM Zaks, Ayal <<a href="mailto:ayal.zaks@intel.com" target="_blank">ayal.zaks@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div class="m_-3607453895660396280m_-6144756284798881861WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Hi Benoit,<u></u><u></u></span></p></div></div><div lang="EN-US" link="blue" vlink="purple"><div class="m_-3607453895660396280m_-6144756284798881861WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">></span> Is there a way (that I missed) to make this happen, or would it require a code change ?<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
</div></div><div lang="EN-US" link="blue" vlink="purple"><div class="m_-3607453895660396280m_-6144756284798881861WordSection1"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">It’s the latter… there’s indeed room to make LV (and SLP) vectorizers optimize for larger more efficient alignment, using static analysis and/or dynamic peeling/versioning
 etc.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Cf. LoadStoreVectorizer’s use of getOrEnforceKnownAlignment().<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">Ayal.<u></u><u></u></span></p>
<p class="MsoNormal"><a name="m_-3607453895660396280_m_-6144756284798881861__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></a></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><a name="m_-3607453895660396280_m_-6144756284798881861______replyseparator"></a><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Mehdi AMINI via llvm-dev<br>
<b>Sent:</b> Thursday, April 12, 2018 01:39<br>
<b>To:</b> <a href="mailto:meister@reservoir.com" target="_blank">meister@reservoir.com</a><br>
<b>Cc:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: [llvm-dev] Loop vectorizer doesn't try to align vectors on preferred vector alignment<u></u><u></u></span></p></div></div><div lang="EN-US" link="blue" vlink="purple"><div class="m_-3607453895660396280m_-6144756284798881861WordSection1">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hi Benoit,<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">Le mer. 11 avr. 2018 à 15:25, Benoit Meister via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> a écrit :<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="line-height:15.0pt;vertical-align:baseline">Hello, <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="line-height:15.0pt;vertical-align:baseline"><u></u> <u></u></p>
</div>
<p class="MsoNormal">I'm playing around with vectorization in LLVM 6.0.0, and I noticed that when creating a vector load out of a scalar load, the  alignment for the vector load is defined to be the one of the scalar load. For instance, 16-bit vectors get aligned
 on 2 bytes. This does not correspond to the preferred alignment for vectors that I specified in the data layout (which is bigger). <u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Inspecting lib/Transforms/Vectorize/LoopVectorizer.cpp, there doesn't seem to be an intent of doing so. <u></u><u></u></p>
<div>
<p class="MsoNormal">I looked at this method in particular: <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><br>
void InnerLoopVectorizer::vectorizeMemoryInstruction<u></u><u></u></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Is there a way (that I missed) to make this happen, or would it require a code change ? Or did I miss anything obvious ?<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">If the original pointer before vectorization is aligned on 2 bytes boundary, the loop vectorizer can't "promote" it to the new alignment without adding checks (or code versioning) right?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Are you in a different case?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Also, did you see this description about the alignment in the data layout in LangRef:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">"The function of the data layout string may not be what you expect. Notably, this is not a specification from the frontend of what alignment the code generator should use.<u></u><u></u></p>
</div>
<div id="m_-3607453895660396280m_-6144756284798881861gmail-data-layout">
<p style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
Instead, if specified, the target data layout is required to match what the ultimate <em>code generator</em> expects. This string is used by the mid-level optimizers to improve code, and this only works if it matches what the ultimate code generator uses. There
 is no way to generate IR that does not embed this target-specific detail into the IR. If you don’t specify the string, the default specifications will be used to generate a Data Layout and the optimization phases will operate accordingly and introduce target
 specificity into the IR with respect to these default specifications."<u></u><u></u></p>
<p style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
Cheers,<u></u><u></u></p>
<p style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
-- <u></u><u></u></p>
<p style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
Mehdi<u></u><u></u></p>
<p style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
 <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div></div><div lang="EN-US" link="blue" vlink="purple"><div class="m_-3607453895660396280m_-6144756284798881861WordSection1"></div>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited</p>

<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></div>

</blockquote></div></blockquote></div>