<div dir="ltr"><div dir="ltr"><div><br></div><div>Hello all,</div><div><br></div><div>It seems that it is insufficient to</div><div>rely on MemorySSA to correctly reorder load/stores.</div><div><br></div><div>For example, we have this following code:</div><div><br></div><div>v = load q</div><div>store 10, p</div><div><br></div><div>=></div><div><br></div><div>store 10, p</div><div>v = load q // This is incorrect if p and q may alias</div><div><br></div><div>In the MemorySSA representation however,</div><div>there's no syntactic dependency between load/store,</div><div>because MemorySSA before transformation would look like this:</div><div><br></div><div>USE(M0) // corresponding to `v = load q`</div><div>M1 = DEF(M0) // corresponding to `store 10, p`</div><div><br></div><div>Reordering these two nodes does not break syntactic dependency,</div><div>hence additional flow-sensitive analysis is needed to check whether reordering is valid.</div><div>To my understanding, GVNHoist seems to do that:</div><div>Memory operations in basic blocks are checked by</div><div>GVNHoist::hasMemoryUse().</div><div><br></div><div><br></div><div>If USE nodes of MemorySSA also have left-hand side, we can correctly</div><div>represent this kind of reorderability IMHO.</div><div><br></div><div>For the example above:</div><div><br></div><div>U1 = USE(M0) // corresponding to `v = load q`</div><div>M1 = DEF(M0, U1) // corresponding to `store 10, p`</div><div><br></div><div>Now there is a syntactic dependency between M1 and U1, hence</div><div>we can syntactically check whether reordering is allowed without any flow-sensitive analysis.</div><div>If the store and load don't alias, we can remove U1 from DEF:</div><div><br></div><div>U1 = USE(M0) // corresponding to `v = load q`</div><div>M1 = DEF(M0) // corresponding to `store 10, p`</div><div><br></div><div>Then, the reordering is valid.</div><div><br></div><div>One issue is regarding PHI node: possible solution is to make</div><div>two kinds of PHIS - PHIs for DEFs & PHIS for USEs, so there are</div><div>at most 2 PHIs.</div><div><br></div><div><br></div><div>Does this idea seem to make sense? Any thoughts?</div><div><br></div><div>Best Regards,</div><div>Juneyoung Lee</div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><br></div><font size="1">Juneyoung Lee</font><div><font size="1">Software Foundation Lab, Seoul National University</font></div></div></div></div></div>