<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 9, 2015, at 2:34 PM, Hal Finkel <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">----- Original Message -----</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">From: "escha" <<a href="mailto:escha@apple.com" class="">escha@apple.com</a>><br class="">To: "Hal Finkel" <<a href="mailto:hfinkel@anl.gov" class="">hfinkel@anl.gov</a>><br class="">Cc: "Matt Arsenault" <<a href="mailto:Matthew.Arsenault@amd.com" class="">Matthew.Arsenault@amd.com</a>>,<span class="Apple-converted-space"> </span><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>, "Justin Holewinski"<br class=""><<a href="mailto:jholewinski@nvidia.com" class="">jholewinski@nvidia.com</a>><br class="">Sent: Sunday, August 9, 2015 7:46:26 AM<br class="">Subject: Re: [llvm-dev] [RFC] BasicAA considers address spaces?<br class=""><br class="">Personally I feel the most intuitive approach would be to have an<br class="">equivalent of isTriviallyDisjoint for IR; we already have a model<br class="">for how it would work, and it could be a TTI call. I’ve kind of<br class="">wanted this for a while because there’s a lot of address-space-esque<br class="">aliasing relationships that can’t be easily modeled on the IR level.<br class=""><br class="">For example (in our model), we have some constraints like this:<br class=""><br class="">Global memory can’t alias local memory.<br class="">Global writeable memory can’t alias global readonly memory (different<br class="">address spaces).<br class="">Stack memory can’t alias global memory (different address spaces).<br class="">Texture reads cannot alias texture writes, because you can’t bind a<br class="">texture as readable and writeable at the same time. Texture writes,<br class="">however, can alias each other.<br class="">Vertex shader outputs can’t really alias each other, even though they<br class="">are technically “stores”.<br class="">(there’s more where that came from)<br class=""><br class="">These are all very trivial to express in code (the trivially disjoint<br class="">function in our backend is like 50 lines of code to cover all the<br class="">cases), but a few of them are slightly more complex than “address<br class="">space A can’t alias B”, so having a generic callback might be nicer<br class="">and more powerful than a “does address space A alias address space<br class="">B” callback, I think.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Could you provide a specific example of a case where the address space is not enough? [maybe you did above, but if so, I don't know which one].</span></div></blockquote><br class=""></div><div>The texture one is the simplest example I can think of:</div><div><br class=""></div><div>Texture writes can alias other texture writes, but cannot alias texture reads, because under the programming model, textures cannot be bound as both read and write. This is equivalent to saying:</div><div><br class=""></div><div>Loads from AS X can alias each other.</div><div>Stores to AS X can alias each other.</div><div>Stores to AS X cannot alias loads from AS X.</div><div><br class=""></div><div>Therefore, texture reads can be freely reordered (they have no memory dependencies), even past texture writes. However, texture writes must be ordered with respect to each other. But they’re all to the same address space.</div><div><br class=""></div><div>I suppose you could hack around this particular case by just marking texture reads as not reading memory (a convenient lie), which I think we’ve already done.</div><div><br class=""></div><div>—escha</div><div><br class=""></div><div><br class=""></div></body></html>