<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><br class=""><blockquote type="cite" class=""><div class="">On Jan 11, 2018, at 11:03 AM, Keno Fischer <<a href="mailto:keno@juliacomputing.com" class="">keno@juliacomputing.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I haven't looked at this code in a while, but I think you'll have to<div class=""><br class=""></div><div class="">1) Add an `else if (Inst->mayReadFromMemory()) { return false; }` after the check for LoadInst in isSafeToMove as a</div><div class="">    correctness fix.</div></div></div></blockquote><div><br class=""></div><div>Is this necessary? I’m fairly sure this should already be covered here:</div><div><br class=""></div><div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">if</span> (<span style="color: #ba2da2" class="">auto</span> CS = CallSite(Inst)) {</div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class="">    </span>// Convergent operations cannot be made control-dependent on additional</div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class="">    </span>// values.</div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">    <span style="color: #ba2da2" class="">if</span> (CS.hasFnAttr(Attribute::Convergent))</div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class="">      </span>return<span style="color: #000000" class=""> </span>false<span style="color: #000000" class="">;</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">    <span style="color: #ba2da2" class="">for</span> (Instruction *S : Stores)</div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">      <span style="color: #ba2da2" class="">if</span> (AA.getModRefInfo(S, CS) & MRI_Mod)</div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class="">        </span>return<span style="color: #000000" class=""> </span>false<span style="color: #000000" class="">;</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">  }</div></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">2) For memory reading instructions you care about add a similar check to the one that's there for LoadInst to recover</div><div class="">    the optimization (if applicable)</div><div class="">3) Change the isa<LoadInst> to mayReadFromMemory in IsAcceptableTarget</div><div class="">4) Add a test for your regression ;)</div></div></div></blockquote><br class=""></div><div>i’m not sure about the test because this only comes up (for us, at least) with out-of-tree intrinsics that access memory (ex: texture reads).</div><div><br class=""></div><div>—escha</div></body></html>