<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 29, 2021 at 3:34 PM Jay Foad <<a href="mailto:jay.foad@gmail.com">jay.foad@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, 29 Mar 2021 at 14:04, Matt Arsenault <<a href="mailto:arsenm2@gmail.com" target="_blank">arsenm2@gmail.com</a>> wrote:<br>
> > On Mar 27, 2021, at 04:56, Jay Foad via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> ><br>
> > Hi Nicolai!<br>
> ><br>
> > For simplicity our regbankselect says that all operands of VALU<br>
> > instructions have to go in vgprs. Moving some of them into sgprs is<br>
> > left as an optimisation for a later pass. As you know there are limits<br>
> > on //how many// operands of a VALU instruction can be sgprs or<br>
> > constants, which are not simple to express in terms of alternative<br>
> > operand mappings.<br>
> ><br>
> > Thanks,<br>
> > Jay.<br>
><br>
><br>
> There are 2 issues:<br>
> 1. Current RegBankSelect does not consider the uses when selecting the bank. This is a general missing optimization<br>
> 2. For the AMDGPU case, I think we should have a post-regbankselect combiner for this. It’s often better to materialize constants for each bank<br></blockquote><div><br></div><div>This sounds desirable, but how would this work on GMIR without interfering in strange ways with pattern matching?</div><div><br></div><div>The challenge I see is: due to the constant bus limitation, there are situations in which such a combiner has to make a choice as to which operand to combine / eliminate the COPY. If the choice is arbitrary, it may sometimes inhibit later pattern matching.</div><div><br></div><div>Related: are we clear on what is legal for GMIR? If G_ADD of regbank sgpr into regbank vgpr is supposed to be legal, does it then have to satisfy the constant bus limitation? If so, why are we still calling it G_ADD instead of V_ADD?<br></div><br><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
><br>
> I don’t think we actually want to have to look through copies, and the places we do are just working around the status quo.<br>
><br>
> The folding SGPR/constants into instructions should be a new and improved version of SIFoldOperands. I think optimizing this is beyond the scope of what RegBankSelect and selection patterns. Far too much code would need to be taught to respect and preserve the constant bus limitation otherwise, so that’s why everything uses VGPRs.<br>
<br>
I can understand leaving it to a later pass to fold //sgprs or<br>
constants// into an instruction. What I can't understand is how you do<br>
the same kind of thing for more complex selection patterns like:<br>
<br>
  t:sgpr = G_ADD y:sgpr, z:sgpr<br>
  t':vgpr = COPY t:sgpr<br>
  r:vgpr = G_ADD x:vgpt, t':vgpr<br>
<br>
How can we select v_add3_u32 from this? I can only think of two options:<br>
<br>
1. Select s_add and v_add and leave it to a later pass to combine<br>
them. This seems to be giving up on doing decent pattern-based<br>
instruction selection.<br>
2. Match it in the instruction selector, using a pattern that<br>
(explicitly or implicitly) looks through the cross-bank copy. But then<br>
you're back to the problem that two of the inputs are sgprs, which may<br>
or may not be valid according to complex operand restrictions.<br></blockquote><div><br></div><div>The SelectionDAG pattern for v_add3 and friends already checks this using a C++ code fragment, doesn't it?</div><div><br></div><div>Cheers,</div><div>Nicolai<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thanks,<br>
Jay.<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">Lerne, wie die Welt wirklich ist,<br>aber vergiss niemals, wie sie sein sollte.</div></div>