<div dir="auto">Thanks, that sounds like it would work. Was this based on what any other target did? Or do any other targets take this approach?<div dir="auto"><br></div><div dir="auto">I just want to make sure that we don't already have a hook suitable for this. Overriding runOnFunction to run what could be described as just a "late SelectionDAG pass" sounds pretty intrusive. Do you remember other approaches that didn't work?</div><div dir="auto"><br></div><div dir="auto">-- Sean Silva</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Dec 22, 2017 2:17 PM, "Simon Dardis" <<a href="mailto:Simon.Dardis@mips.com">Simon.Dardis@mips.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Hi Sean,
<div><br>
</div>
<div>Have you looked at inheriting from llvm:SelectionDAGISel for your target, invoking runOnMachineFunction to perform</div>
<div>ISEL, then post processing <span style="font-size:10pt">the output by finding the cases where -1 is synthesized then used and replacing the uses</span></div>
<div><span style="font-size:10pt">of the synthesized -1 with the register wired to -1?</span></div>
<div><br>
</div>
<div>The MIPS backend takes this approach for dealing with the zero register, see MipSEISelDAGToDAG.cpp for reference.</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Simon<br>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<hr>
<div id="m_4833981333199045773divRpF382613" style="direction:ltr"><font face="Tahoma" size="2" color="#000000"><b>From:</b> llvm-dev [<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.<wbr>org</a>] on behalf of Sean Silva via llvm-dev [<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>]<br>
<b>Sent:</b> Friday, December 22, 2017 5:22 AM<br>
<b>To:</b> llvm-dev<br>
<b>Subject:</b> [llvm-dev] Canonical way to handle zero registers?<br>
</font><br>
</div>
<div></div>
<div>
<div dir="auto">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.
<div dir="auto"><br>
</div>
<div dir="auto">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".</div>
<div dir="auto"><br>
</div>
<div dir="auto">Thanks,</div>
<div dir="auto">Sean Silva</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote></div></div>