<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="">Hi Ryan,<div class=""><br class=""></div><div class="">The hook you have to use is addPreRewrite.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">-Quentin<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 20, 2019, at 11:17 AM, Ryan Taylor <<a href="mailto:ryta1203@gmail.com" class="">ryta1203@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Quentin, </div><div class=""><br class=""></div><div class=""> Can you be more specific please? If I call the pass in addPostRegAlloc llc crashes after Slot index numbering with:</div><div class=""><br class=""></div><div class="">LLVM ERROR: Invalid global physical register </div><div class=""><br class=""></div><div class="">I'm not sure how this makes sense.</div><div class=""><br class=""></div><div class="">-Ryan</div></div><br class=""><div class="gmail_quote"><div class="gmail_attr" dir="ltr">On Wed, Nov 20, 2019 at 12:41 PM Quentin Colombet <<a href="mailto:qcolombet@apple.com" class="">qcolombet@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="auto" class="">I think doing that before reg alloc (and thus right after phi elimination) is too early.<div class=""><br class=""></div><div class="">By doing this that early we will lose the opportunity to coalesce all the copies.</div><div class="">In other words what I am saying is a bunch of copies may be worse than just a few load immediate, but one load immediate reused thanks to copy coalescing is better than a few load immediate.</div><div class=""><br class=""></div><div class="">My 2c ;)<br class=""><div dir="ltr" class=""><br class=""><blockquote type="cite" class="">Le 20 nov. 2019 à 08:47, Ryan Taylor <<a href="mailto:ryta1203@gmail.com" target="_blank" class="">ryta1203@gmail.com</a>> a écrit :<br class=""><br class=""></blockquote></div><blockquote type="cite" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">I was looking at writing a pass after PHI elim to do this, just trying to dump the reaching def MIs but get lots of no live segments issues. Have included addREquired and addPreserved for LiveIntervals and setPreservesAll().</div><div class=""><br class=""></div><div class="">-Ryan</div></div><br class=""><div class="gmail_quote"><div class="gmail_attr" dir="ltr">On Fri, Nov 15, 2019 at 2:58 PM Quentin Colombet <<a href="mailto:qcolombet@apple.com" target="_blank" class="">qcolombet@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div class="">You could do it after RA and before rewrite, when you still have the live intervals around.<br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Nov 15, 2019, at 11:16 AM, Ryan Taylor <<a href="mailto:ryta1203@gmail.com" target="_blank" class="">ryta1203@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div style="text-align:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:Arial,Helvetica,sans-serif;font-size:13.33px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;white-space:normal" dir="ltr" class="">This would require getting the reaching definition which requires live intervals analysis.</div><br class=""></div></div><br class=""><div class="gmail_quote"><div class="gmail_attr" dir="ltr">On Thu, Nov 14, 2019 at 12:15 PM Quentin Colombet <<a href="mailto:qcolombet@apple.com" target="_blank" class="">qcolombet@apple.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">That sounds like the folding could be done when you expand the copy in expand pseudo after regalloc.<br class="">
<br class="">
> On Nov 14, 2019, at 12:20 AM, Arsenault, Matthew <<a href="mailto:Matthew.Arsenault@amd.com" target="_blank" class="">Matthew.Arsenault@amd.com</a>> wrote:<br class="">
> <br class="">
> In this case the load imm is foldable into the copy, once converted to a mov. Directly folding this would be 4 v_mov_b32 instead of 5 produced currently<br class="">
> <br class="">
> -Matt<br class="">
> <br class="">
> On 11/14/19, 07:20, "llvm-dev on behalf of Quentin Colombet via llvm-dev" <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank" class="">llvm-dev-bounces@lists.llvm.org</a> on behalf of <a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class="">
> <br class="">
> Hi Ryan,<br class="">
> <br class="">
> Unless you can fold your immediate directly in an instruction, it is actually not profitable to propagate them. Indeed you will end up with a bunch of load imm instead of reusing a register that already hold this value.<br class="">
> <br class="">
> The way it works right now is, if holding this value in a register is too expensive, i.e., it triggers a spill, then we rematerialize the immediate instead of holding a register for it.<br class="">
> <br class="">
> Cheers,<br class="">
> -Quentin<br class="">
> <br class="">
>> On Nov 13, 2019, at 7:36 AM, Ryan Taylor via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class="">
>> <br class="">
>> I have some code such that:<br class="">
>> <br class="">
>> vgpr1 = mov 0<br class="">
>> branch bb<br class="">
>> bb:<br class="">
>> PHI vgpr2 = vgpr1, ….<br class="">
>> PHI vgpr3 = vgpr1, ….<br class="">
>> PHI vgpr4 = vgpr1, ….<br class="">
>> PHI vgpr5 = vgpr1, ….<br class="">
>> <br class="">
>> PHI node elimination is generating copies for all these PHIs (and hoisting them) as such:<br class="">
>> <br class="">
>> vgpr1 = 0<br class="">
>> vgpr20 = COPY vgpr1 // old vgpr2<br class="">
>> vgpr30 = COPY vgpr1 // old vgpr3<br class="">
>> vgpr40 = COPY vgpr1 // old vgpr4<br class="">
>> vgpr 50 = COPY vgprt1 // old vgpr5<br class="">
>> <br class="">
>> I expect the zero to get propagated in a later phase but it's not. I was looking at adding immediate folding to the register coalescer but this doesn't really seem like the right place. Any suggestions?<br class="">
>> <br class="">
>> I'm sort of surprised that other targets haven't run into this issue.<br class="">
>> <br class="">
>> -Ryan<br class="">
>> <br class="">
>> <br 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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" rel="noreferrer" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="">
> <br 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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" rel="noreferrer" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class="">
> <br class="">
> <br class="">
<br class="">
</blockquote></div>
</div></blockquote></div><br class=""></div></blockquote></div>
</div></blockquote></div></div></blockquote></div>
</div></blockquote></div><br class=""></div></body></html>