<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></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 Sep 10, 2018, at 4:53 PM, Preston Briggs <<a href="mailto:preston.briggs@gmail.com" class="">preston.briggs@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><br class="">> The underlying liveness datastructure is a list of ranges where each vreg is alive</div><div class="gmail_quote">> (ranges in terms of instructions numbered). I remember a couple of later linear scan</div><div class="gmail_quote">> papers describing the same thing (Traub <a href="http://et.al/" class="">et.al</a>. being the first if I remember correctly).</div><div class="gmail_quote">> That should be as accurate as you can get in terms of liveness information.<div class=""><br class=""></div><div class="">It depends on the details.</div><div class="">For example, given</div><div class=""><br class=""></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class="">t0 = mumble</font></div></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class="">if (something) {</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class=""> t2 = 3</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class="">}</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class="">else {</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class=""> t3 = t0 + 3</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class=""> print t0</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class="">}</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class="">t4 = phi(t2, t3)</font></div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">it's clear that t2 and t0 shouldn't interfere,</div><div class="">but some folks might say the ranges overlap.</div></div></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">Similarly,</div><div class=""><br class=""></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class="">t6 = mumble</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class="">t7 = t6</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class="">t8 = t6 + 5</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class="">t9 = t7 + 10</font></div></div></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><font face="monospace, monospace" class="">print t8, t9</font></div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">Chaitin points out that t6 and t7 shouldn't interfere,</div><div class="">even though the live ranges overlap.</div></div></div></div></div></blockquote><div><div>- We go out of SSA form before allocating registers so you won't see phi instruction.</div><div>- In the second case the copy coalesceing pass should have coalesced t6 and t7.</div><div><br class=""></div><div>I would expect both cases to work as you expect.</div><div><br class=""></div><div>- Matthias</div><blockquote type="cite" class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"></div></div></div></blockquote></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class="">Anyway, I'll look at the links.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Preston</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class=""><div class=""><br class=""></div><div class="">We have separate aggressive coalescing pass before allocation. The register allocator will later perform live range splitting inside the main allocation loop as it seems fit.</div><span class=""><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">I ask these questions because we (guys I work with) see loops</div><div class="">where there's a little register juggling that seems unnecessary.</div></div></div></blockquote></span><div class="">Well your best bet is to learn reading the output of `-mllvm -print-machineinstrs -mllvm -debug-only=regalloc` (which can take a while)...</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Is there a paper that describes what y'all do?</div></div></div></blockquote><div class=""><br class=""></div></span><div class="">I'm only aware of a blog post:</div><div class=""><a href="http://blog.llvm.org/2011/09/greedy-register-allocation-in-llvm-30.html" target="_blank" class="">http://blog.llvm.org/2011/09/<wbr class="">greedy-register-allocation-in-<wbr class="">llvm-30.html</a></div><div class="">and a dev conference talk in 2011:</div><div class=""><a href="https://llvm.org/devmtg/2011-11/" target="_blank" class="">https://llvm.org/devmtg/2011-<wbr class="">11/</a></div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">- Matthias</div></font></span><span class=""><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Preston</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Sep 10, 2018 at 9:57 AM, Matthias Braun <span dir="ltr" class=""><<a href="mailto:mbraun@apple.com" target="_blank" class="">mbraun@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class="">I would not describe LLVMs register allocator as linear scan, it's closer to graph coloring than linear scan IMO (though doesn't really matcher either approach).<div class=""><br class=""></div><div class="">RegAllocGreedy assigns the registers in an order based on the priority value computed in enqueu() we are not just scanning from top to bottom of the program. We also perform actual interference checks we just don't happen to build up an explicit interference graph up front.</div><div class=""><br class=""></div><div class="">- Matthias</div><div class=""><br class=""></div><div class=""><div class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="m_-4050234212288967131h5"><div class="">On Sep 10, 2018, at 9:49 AM, Preston Briggs via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="m_-4050234212288967131m_-5434489890348760605Apple-interchange-newline"></div></div><div class=""><div class=""><div class="m_-4050234212288967131h5"><div dir="ltr" class="">Why have we ended up using linear-scan register allocation<div class=""><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline" class="">by default (instead of, e.g., coloring)?</span><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial" class=""><br class=""></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial" class="">Thanks,</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial" class="">Preston</div><div class="m_-4050234212288967131m_-5434489890348760605gmail-yj6qo" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"></div><br class="m_-4050234212288967131m_-5434489890348760605gmail-Apple-interchange-newline"></div><br class=""></div></div></div>
______________________________<wbr class="">_________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></span></div><br class=""></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>