<div dir="ltr">Hi Andreas,<br><div class="gmail_extra"><br><div class="gmail_quote">2017-03-14 11:56 GMT+01:00 Andreas Scherman via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>The example in the docs[1] states that the LLVM concurrency model does not allow the hoisting of loads and introduction of local variables due to another thread potentially altering the value whilst running the function. <br></div></div></blockquote><div>As a possible clarification: The optimization restriction you cite only applies to stores to possibly shared variables. Speculative loads are legal.</div><div><br></div><div>In the example in the docs, the offending bit is not loading x into a local variable xtemp, but unconditionally storing xtemp back into x. Emphasis on `unconditionally`. I.e., if it weren't for the `if (a[i])` in the original piece of code, the transformation would be legal!</div><div><br></div><div>Best,</div><div>Philip</div></div></div></div>