<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 17, 2019, at 10:00 AM, Neil Ryan <<a href="mailto:neilryan@cs.washington.edu" class="">neilryan@cs.washington.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<title class=""></title>
<div class="">
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">So, volatile’s been a fine solution — the issue is volatile pointers would perform the load every time; ideally memory accesses would be able to be cached. This is why I’ve been leaning towards disabling the part of instcombine that combines memory accesses instead of using volatile — there should be better performance.</div></div></div></blockquote><div><br class=""></div><div>Why do you want this?</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="">
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">On Apr 17, 2019, 9:54 AM -0700, Jameson Nash <<a href="mailto:vtjnash@gmail.com" class="">vtjnash@gmail.com</a>>, wrote:<br class="">
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">The lang ref promises that, "the backend should never ... merge target-legal volatile load/store instructions". Which I've usually assumed meant that it was promised? Just curious if you thought this left some wiggle room for some optimizations, since my impression was that someone wanted to let you know that it's dependable. Likewise, there's also the clause that "The optimizers must not change the number of volatile operations", which doesn't seem to explicitly forbid merging, but does seem to me like it would make it difficult to find a case where it would be profitable.</div>
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, Apr 17, 2019 at 12:35 PM JF Bastien via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class=""></div>
<blockquote class="gmail_quote" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;">
<div style="word-wrap:break-word;line-break:after-white-space" class=""><br class="">
<div class="">
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #3498db;" class="">
<div class="">On Apr 17, 2019, at 5:02 AM, Arsenault, Matthew via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:</div>
<br class="gmail-m_-6774904596322180241Apple-interchange-newline">
<div class="">
<div class="gmail-m_-6774904596322180241WordSection1" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif" class="">This won’t happen with volatile load/store</div>
</div>
</div>
</blockquote>
<div class=""><br class=""></div>
<div class="">This is mostly true today, but AFAICT the LLVM memory model doesn’t actually offer this guarantee. It merely says that LLVM treats volatile like C / C++ treats volatile… which isn’t much of a guarantee because C / C++ volatile doesn’t normatively mean anything. Specifically, we cannot really honor this when volatile bitfields are used for which memory operations don’t exist:</div>
<div class=""><br class=""></div>
</div>
<blockquote style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #3498db;" class="">
<div class="">
<div class=""><font face="Courier" class="">struct {</font></div>
</div>
<div class="">
<div class=""><font face="Courier" class=""> volatile int a : 12;</font></div>
</div>
<div class="">
<div class=""><font face="Courier" class=""> volatile int b : 4;</font></div>
</div>
<div class="">
<div class=""><font face="Courier" class="">} s;</font></div>
</div>
</blockquote>
<div class="">
<div class=""><br class=""></div>
<div class="">As things stand, we haven’t promised that we won’t combine adjacent volatile stores, and C / C++ certainly allow us to do so. I don’t think it would be a good idea to do so, but we certainly could.</div>
<div class=""><br class=""></div>
<br class="">
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #3498db;" class="">
<div class="">
<div class="gmail-m_-6774904596322180241WordSection1" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif" class=""><span style="font-size:11pt" class=""> </span><span style="font-size:11pt" class="">-Matt</span> </div>
</div>
</div>
</blockquote>
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #3498db;" class="">
<div class="gmail-m_-6774904596322180241WordSection1" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif" class=""><u class=""></u><u class=""></u></div>
<div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif" class=""><u class=""></u> <u class=""></u></div>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(181,196,223);padding:3pt 0in 0in" class="">
<div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif" class=""><b class=""><span style="font-size:12pt" class="">From:<span class="gmail-m_-6774904596322180241Apple-converted-space"> </span></span></b><span style="font-size:12pt" class="">llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank" class="">llvm-dev-bounces@lists.llvm.org</a>> on behalf of llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>><br class="">
<b class="">Reply-To:<span class="gmail-m_-6774904596322180241Apple-converted-space"> </span></b>Neil Ryan <<a href="mailto:neilryan@cs.washington.edu" target="_blank" class="">neilryan@cs.washington.edu</a>><br class="">
<b class="">Date:<span class="gmail-m_-6774904596322180241Apple-converted-space"> </span></b>Tuesday, April 16, 2019 at 9:01 PM<br class="">
<b class="">To:<span class="gmail-m_-6774904596322180241Apple-converted-space"> </span></b>llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>><br class="">
<b class="">Subject:<span class="gmail-m_-6774904596322180241Apple-converted-space"> </span></b>[llvm-dev] Disable combining of loads and stores in instcombine<u class=""></u><u class=""></u></span></div>
</div>
<div class="">
<div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif" class=""><u class=""></u> <u class=""></u></div>
</div>
<div name="messageBodySection" class="">
<div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif" class=""><span style="font-size:10.5pt;font-family:Arial,sans-serif" class=""> 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<span class="gmail-m_-6774904596322180241Apple-converted-space"> </span><a href="http://llvm.1065342.n5.nabble.com/disabling-combining-load-stores-in-optimizer-td37560.html" style="color:purple;text-decoration:underline" target="_blank" class="">this thread</a> from 2009 -- it seems like it wasn't possible then. Has anything changed since? <u class=""></u><u class=""></u></span></div>
</div>
<div name="messageSignatureSection" class="">
<div style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif" class=""><span style="font-size:10.5pt;font-family:Arial,sans-serif" class=""><br class="">
Neil<u class=""></u><u class=""></u></span></div>
</div>
</div>
<span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline" class="">_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none" class="">
<span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline" class="">LLVM Developers mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none" class="">
<span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline" class=""><a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a></span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none" class="">
<span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline" class=""><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></span></blockquote>
</div>
<br class=""></div>
_______________________________________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""></blockquote>
</div>
</blockquote>
</div>
</div>
</div></blockquote></div><br class=""></body></html>