<p dir="ltr">Fwiw it's been established that nvptx pre Volta needs this, or at least a more limited version that puts  syncthreads calls at the end of a single-entrance single-exit region.  The reason we haven't just turned it on is, as you say, it seems quite buggy as-is, and I also wasn't able to understand its algorithm.</p>
<p dir="ltr">I hope we'll be able to look at this in Q1 or Q2, although it's contingent on a lot of things.  Currently I also think it's in need of a rewrite.</p>
<br><div class="gmail_quote"><div dir="ltr">On Thu, Dec 28, 2017, 5:53 PM Matt Arsenault via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">arsenm added a comment.<br>
<br>
In <a href="https://reviews.llvm.org/D41605#964650" rel="noreferrer" target="_blank">https://reviews.llvm.org/D41605#964650</a>, @dberlin wrote:<br>
<br>
><br>
<br>
<br>
<br>
<br>
> You would currently detect this as some form of loop, but again, most of the algorithms used here do not look like the ones i'm familiar with (I feel like i can find a ton of edge cases in it).<br>
<br>
There are definitely a lot of strange things going on here and I don't really understand how this manages to work at all. I think part of the problem was using RegionInfo for this was a mistake, and this should probably be rewritten to not depend on it. For example because the pass itself only sees one region at a time, it won't even see the example you posted as something it can try to process. There isn't a well formed single exit region, so I think the pass will just see the function top level region and bail out. I've variants of the same problem pop up from time to time. Fundamentally using an analysis to look at well formed regions probably doesn't make sense for a pass which is trying to produce well formed regions. I've also been surprised by some of the visitation order decisions for the various graph iterators with RegionNode compared to the same orders over the entire function. The various places that need to differently handle subregion nodes vs. individual blocks also seems more confusing to me.<br>
<br>
<br>
<a href="https://reviews.llvm.org/D41605" rel="noreferrer" target="_blank">https://reviews.llvm.org/D41605</a><br>
<br>
<br>
<br>
</blockquote></div>