<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">I think doing that before reg alloc (and thus right after phi elimination) is too early.<div><br></div><div>By doing this that early we will lose the opportunity to coalesce all the copies.</div><div>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><br></div><div>My 2c ;)<br><div dir="ltr"><br><blockquote type="cite">Le 20 nov. 2019 à 08:47, Ryan Taylor <ryta1203@gmail.com> a écrit :<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div>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><br></div><div>-Ryan</div></div><br><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">qcolombet@apple.com</a>> wrote:<br></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 style="overflow-wrap: break-word;">You could do it after RA and before rewrite, when you still have the live intervals around.<br><div><br><blockquote type="cite"><div>On Nov 15, 2019, at 11:16 AM, Ryan Taylor <<a href="mailto:ryta1203@gmail.com" target="_blank">ryta1203@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div dir="ltr"><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">This would require getting the reaching definition which requires live intervals analysis.</div><br></div></div><br><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">qcolombet@apple.com</a>> wrote:<br></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>
<br>
> On Nov 14, 2019, at 12:20 AM, Arsenault, Matthew <<a href="mailto:Matthew.Arsenault@amd.com" target="_blank">Matthew.Arsenault@amd.com</a>> wrote:<br>
> <br>
> 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>
> <br>
> -Matt<br>
> <br>
> 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">llvm-dev-bounces@lists.llvm.org</a> on behalf of <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> <br>
>    Hi Ryan,<br>
> <br>
>    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>
> <br>
>    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>
> <br>
>    Cheers,<br>
>    -Quentin<br>
> <br>
>> On Nov 13, 2019, at 7:36 AM, Ryan Taylor via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>> <br>
>> I have some code such that:<br>
>> <br>
>> vgpr1 = mov 0<br>
>> branch bb<br>
>> bb:<br>
>> PHI vgpr2 = vgpr1, ….<br>
>> PHI vgpr3 = vgpr1, ….<br>
>> PHI vgpr4 = vgpr1, ….<br>
>> PHI vgpr5 = vgpr1, ….<br>
>> <br>
>> PHI node elimination is generating copies for all these PHIs (and hoisting them) as such:<br>
>> <br>
>> vgpr1 = 0<br>
>> vgpr20 = COPY vgpr1 // old vgpr2<br>
>> vgpr30 = COPY vgpr1 // old vgpr3<br>
>> vgpr40 = COPY vgpr1 // old vgpr4<br>
>> vgpr 50 = COPY vgprt1 // old vgpr5<br>
>> <br>
>> 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>
>> <br>
>> I'm sort of surprised that other targets haven't run into this issue.<br>
>> <br>
>> -Ryan<br>
>> <br>
>> <br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" rel="noreferrer">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
> <br>
>    _______________________________________________<br>
>    LLVM Developers mailing list<br>
>    <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>    <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" rel="noreferrer">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
> <br>
> <br>
<br>
</blockquote></div>
</div></blockquote></div><br></div></blockquote></div>
</div></blockquote></div></body></html>