<div dir="ltr"><div><span style="font-family:arial,sans-serif;font-size:13px">Hi Chandler,</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Nebbing in with my two-pennyworth;</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span style="font-family:arial,sans-serif;font-size:13px">Also, with the IR produced by SROA, the information needed is still present. I think the problem is that both backends need to be taught the trick of using multiple stores at indexed offsets to save math combining two values. That's my suggestion for how to improve the quality of code for these patterns.</span></blockquote>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div>I think while it's easy to ask the backend to do this, SROA runs fairly early and there are many things in between it and the backend.</div>
<div><br></div><div>My first concern is that the additional IR instructions diverge greatly from the expected generated code, which breaks the SLP and loop vectorizers' heuristics.</div><div><br></div><div>Secondly, there is no guarantee that the inserted zexts/sexts/or's will still be in a coherent group for the backend to identify. If other midend passes manage to remove or combine one or more of them, the idiom may no longer be matched. Or worse, if part of them are lifted or sunk into a different basic block our instruction selection will never see them!</div>
<div><br></div><div>So I'm not sure your proposed solution is the best available.</div><div><br></div><div>Cheers,</div><div><br></div><div>James</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 29 August 2014 10:23, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@gmail.com" target="_blank">chandlerc@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div class="">On Wed, Aug 27, 2014 at 8:46 PM, Hao Liu <span dir="ltr"><<a href="mailto:Hao.Liu@arm.com" target="_blank">Hao.Liu@arm.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I think you concern about when the narrow LOADs are folded back, we can’t fuse the narrow STOREs back. Am I get your point?</span></p>

</blockquote><div><br></div></div><div>No, my concern is about when we completely remove the loads through GVN or even the mem2reg process that runs in SROA itself. The sliced loads are expected to go away and become SSA registers. We might well be able to then fold away the zext / shl / or / etc into the math that feeds those SSA values. But we will in most cases fail to fuse the stores back together once they are split.</div>
<div class="">
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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">But I think the narrow LOADs won’t be folded back, as the SROA checks such LOAD can be split and removed. So if the narrow LOADs won’t exist, there are two choices for us:<u></u><u></u></span></p>

<p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>(1)<span style="font:7.0pt "Times New Roman"">    </span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">The additional ZEXT/SHL/OR and wide STORE.<u></u><u></u></span></p>

<p><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><span>(2)<span style="font:7.0pt "Times New Roman"">    </span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Two narrow STOREs.<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I still prefer the (2) than the (1). I think a better optimization for (1) is to split the STORE. Even if there are other optimizations to change the wide STORE, we’ll still have ZEXT/SHL/OR left. Such code with bit math seems not the best choice.</span></p>

</blockquote><div><br></div></div><div>I'm not really sure what you mean about having instructions left over.</div><div><br></div><div>The fundamental thing is this: the width of memory stored to is actually a very important property of the source program. It clarifies the maximum width of memory that is correct to store two in a single instruction. Splitting or narrowing a store is often irreversible because fusing or widening can introduce data races.</div>

<div><br></div><div>As a consequence, it is a conscious choice throughout the optimizer to preserve the maximal width of stores (and to a lesser extend loads). This preserves the information in the middle-end about what freedoms the source program has w.r.t. to memory accesses and data races.</div>

<div><br></div><div><br></div><div>Also, with the IR produced by SROA, the information needed is still present. I think the problem is that both backends need to be taught the trick of using multiple stores at indexed offsets to save math combining two values. That's my suggestion for how to improve the quality of code for these patterns.</div>

</div></div></div>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>