<div dir="ltr"><div dir="ltr"><div>Step back: where exactly in instcombine is this load/store combining happening? I thought we don't do that for precisely the reasons stated in this thread.<br></div><div><br></div><div>We used to have a dedicated IR pass for load combining that was removed:</div><div><a href="https://reviews.llvm.org/rL306067">https://reviews.llvm.org/rL306067</a><br></div><div><br></div><div>We definitely do some load/store combining in SelectionDAG, but that should all be preventable using target hooks.<br></div><div><br></div><div>AFAICT, the place this happens in IR is the -memcpyopt pass? If that's the problem, then how about adding a TargetTransformInfo dependence/hook there to stop this transform?<br></div><div><br></div></div></div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 19, 2019 at 2:54 PM Neil Ryan via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>
<div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif">Sorry, I meant that if I have a series of character loads that get combined into a single word load, I don’t know of a way to 1) know that the word load was originally comprised of character loads and 2) decompose the word load back into character loads.
<div>Granted, if I have (1), (2) just a matter of inserting the right ops. I’ve been digging into MachineMemOperand — I’m not entirely sure what methods in this class can get me this information. Any pointers would be much appreciated.</div>
</div>
<div name="messageSignatureSection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif"><br>
<div class="gmail-m_-4018042991282404007gmail-m_-5812174262741101857matchFont">Neil</div>
</div>
<div name="messageReplySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif">On Apr 18, 2019, 1:45 PM -0700, Arsenault, Matthew <<a href="mailto:Matthew.Arsenault@amd.com" target="_blank">Matthew.Arsenault@amd.com</a>>, wrote:<br>
<blockquote type="cite" style="margin:5px;padding-left:10px;border-left:thin solid rgb(26,188,156)">
<div class="gmail-m_-4018042991282404007gmail-m_-5812174262741101857WordSection1">
<p class="MsoNormal">I’m not sure what you mean by this. The type in memory doesn’t really mean anything, and no information is lost. You can still tell (for optimizations) some information about the underlying IR object from the MachineMemOperand, which is mostly used for alias analysis.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">-Matt</p>
<p class="MsoNormal"> </p>
<div style="border-color:rgb(181,196,223) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12pt;color:black">From:</span></b> <span style="font-size:12pt;color:black">Neil Ryan <<a href="mailto:neilryan@cs.washington.edu" target="_blank">neilryan@cs.washington.edu</a>><br>
<b>Date:</b> Thursday, April 18, 2019 at 9:59 PM<br>
<b>To:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>, "<a href="mailto:tstellar@redhat.com" target="_blank">tstellar@redhat.com</a>" <<a href="mailto:tstellar@redhat.com" target="_blank">tstellar@redhat.com</a>>, "Arsenault, Matthew" <<a href="mailto:Matthew.Arsenault@amd.com" target="_blank">Matthew.Arsenault@amd.com</a>><br>
<b>Subject:</b> Re: [llvm-dev] Disable combining of loads and stores in instcombine</span></p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div name="messageBodySection">
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif">IIRC it’s not strictly possible to determine what array a load/store is based on. I don’t believe the decomposition is always possible, as information is lost when accesses are combined.</span></p>
</div>
<div name="messageSignatureSection">
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif"><br>
Neil</span></p>
</div>
<div name="messageReplySection">
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif">On Apr 17, 2019, 12:31 PM -0700, Arsenault, Matthew <<a href="mailto:Matthew.Arsenault@amd.com" target="_blank">Matthew.Arsenault@amd.com</a>>, wrote:<br>
<br></span></p>
<blockquote style="margin:5px;padding-left:10px;border-left:thin solid rgb(230,126,34)">
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif">This is really a codegen problem. You can decompose the load/store however you like in the backend. InstCombine should still combine the loads as a canonicalization.</span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif"> </span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif">-Matt</span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif"> </span></p>
<div style="border-color:rgb(181,196,223) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12pt;font-family:"Arial",sans-serif;color:black">From:</span></b> <span style="font-size:10.5pt;font-family:"Arial",sans-serif"></span><span style="font-size:12pt;font-family:"Arial",sans-serif;color:black">llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>> on behalf of llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Reply-To:</b> Neil Ryan <<a href="mailto:neilryan@cs.washington.edu" target="_blank">neilryan@cs.washington.edu</a>><br>
<b>Date:</b> Wednesday, April 17, 2019 at 9:28 PM<br>
<b>To:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>, "<a href="mailto:tstellar@redhat.com" target="_blank">tstellar@redhat.com</a>" <<a href="mailto:tstellar@redhat.com" target="_blank">tstellar@redhat.com</a>><br>
<b>Subject:</b> Re: [llvm-dev] Disable combining of loads and stores in instcombine</span><span style="font-size:10.5pt;font-family:"Arial",sans-serif"></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif"> </span></p>
</div>
<div name="messageBodySection">
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif">I’m writing a pass for some custom hardware — we’d like to split arrays across hardware elements; this doesn’t work if consecutive writes to characters get combined to a word.</span><span style="font-size:10.5pt;font-family:"Arial",sans-serif"></span></p>
</div>
<div name="messageReplySection">
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:10.5pt;font-family:"Arial",sans-serif">On Apr 16, 2019, 8:17 PM -0700, Tom Stellard <<a href="mailto:tstellar@redhat.com" target="_blank">tstellar@redhat.com</a>>, wrote:</span><span style="font-size:10.5pt;font-family:"Arial",sans-serif"></span></p>
<blockquote style="margin:5px;padding-left:10px;border-left:thin solid rgb(52,152,219)">
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:10.5pt;font-family:"Arial",sans-serif">On 04/16/2019 11:38 AM, Neil Ryan via llvm-dev wrote:</span><span style="font-size:10.5pt;font-family:"Arial",sans-serif"></span></p>
<blockquote style="margin:5px;padding-left:10px;border-left:thin solid rgb(211,84,0)">
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:10.5pt;font-family:"Arial",sans-serif">LLVM's optimizer combines stores to consecutive characters into a write of a single word. For instance, if I have char A[4] and I write some static value to each element, these writes would be combined into a single 32-bit word write. I found this thread <<a href="http://llvm.1065342.n5.nabble.com/disabling-combining-load-stores-in-optimizer-td37560.html" target="_blank">http://llvm.1065342.n5.nabble.com/disabling-combining-load-stores-in-optimizer-td37560.html</a>> from 2009 -- it seems like it wasn't possible then. Has anything changed since?</span><span style="font-size:10.5pt;font-family:"Arial",sans-serif"></span></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:10.5pt;font-family:"Arial",sans-serif"><br>
Why do you want to disable this optimization?<br>
<br>
-Tom<br>
<br>
<br></span> <span style="font-size:10.5pt;font-family:"Arial",sans-serif"></span></p>
<blockquote style="margin:5px;padding-left:10px;border-left:thin solid rgb(211,84,0)">
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:10.5pt;font-family:"Arial",sans-serif">Neil<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></span><span style="font-size:10.5pt;font-family:"Arial",sans-serif"></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif"> </span><span style="font-size:10.5pt;font-family:"Arial",sans-serif"></span></p>
</blockquote>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>