<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 3 Jan 2018, at 19:44, Sean Silva <<a href="mailto:chisophugis@gmail.com" class="">chisophugis@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Jan 2, 2018 at 8:28 AM, Daniel Sanders <span dir="ltr" class=""><<a href="mailto:daniel_l_sanders@apple.com" target="_blank" class="">daniel_l_sanders@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Sean,<br class="">
<br class="">
Just to give the GlobalISel perspective on this,</blockquote><div class=""><br class=""></div><div class="">Thanks for chiming in!<br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> GlobalISel supports the declaration of a zero register in the register class like so:<br class="">
        def GPR32z : RegisterOperand<GPR32> {<br class="">
          let GIZeroRegister = WZR;<br class="">
        }<br class="">
With that definition, the tablegen-erated ISel code will try to replace will try to replace 'G_CONSTANT s32 0' with WZR whenever the operand is specified as GPR32z.<br class=""></blockquote><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Is this method extensible to the case of other hardwired register values? Tracing through the code, I noticed that it seems to boil down to a GIR_CopyOrAddZeroReg opcode, which seems like a pretty deep embedding of the specialness of zero.</div></div></div></div></div></blockquote><div><br class=""></div><div>At the moment, zero is hardwired since losing an AArch64 optimization was the motivating case behind adding it and the only other hardwired register I knew about was Mips's $0 but I see no reason we couldn't expand on it with a target hook of some kind.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">Also, IIUC, GPR32z is defining a special reg class that enables the zero-register transformation. Defining a new reg class seems pretty heavyweight for this; is there ever a situation where you wouldn't want the zero-register transformation to fire so you could just put this on GPR32 itself? I noticed that there actually aren't very many uses of GPR32z which seems strange, as I would expect most instructions could make use of the zero register.</div></div></div></div></div></blockquote><div><br class=""></div><div>I haven't got around to rolling it out to GPR32 yet, we think it's safe to do that but there are a couple instructions where wzr/xzr aren't permitted. At the moment, it's on the instructions that lost the optimization when tablegen took over from the C++.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">Thanks,</div><div class=""><br class=""></div><div class="">-- Sean Silva</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="gmail-HOEnZb"><div class="gmail-h5"><br class="">
> On 21 Dec 2017, at 21:22, Sean Silva via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:<br class="">
><br class="">
> I looked around the codebase and didn't see anything that obviously looked like the natural place to turn constant zero immediates into zero-registers (i.e. registers that always return zero when read). Right now we are expanding them in ISelLowering::LowerOperation but that seems too early.<br class="">
><br class="">
> The specific issue I'm hitting is that we have a register that reads as -1 and so when we replace -1 too early with this register, the standard "not" pattern (xor x, -1) will fail to match to "not".<br class="">
><br class="">
> Thanks,<br class="">
> Sean Silva<br class="">
</div></div><div class="gmail-HOEnZb"><div class="gmail-h5">> ______________________________<wbr class="">_________________<br class="">
> LLVM Developers mailing list<br class="">
> <a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class="">
<br class="">
</div></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>