<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi again.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">One solution could be to do something like this:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">// Let the pseudo define X0 but use the larger regclass.<o:p></o:p></p>
<p class="MsoNormal">let Defs = [X0] in {<o:p></o:p></p>
<p class="MsoNormal">def MyPseudo: SomePseudoInstr<<o:p></o:p></p>
<p class="MsoNormal"> (outs …), (ins Xrc:$src, …),<o:p></o:p></p>
<p class="MsoNormal"> …>;<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">And then when expanding the pseudo, late, typically after register allocation, you might need to introduce a copy from the src register picked by regalloc to X0 before the actual instruction.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">/Björn<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> <b>On Behalf Of
</b>Björn Pettersson A via llvm-dev<br>
<b>Sent:</b> den 29 mars 2021 23:55<br>
<b>To:</b> David Callahan <david.callahan1@live.com>; llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> Re: [llvm-dev] Register constraints for implicit register usage<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I was about to say that TargetRegisterInfo::shouldCoalesce can be overridden by the target to prevent coalescing. But it looks like MachineCSE is doing coalescing/propagation without considering that target hook.<o:p></o:p></p>
<p class="MsoNormal">Maybe there should be a similar interface (unless shouldCoalesce can be used) to allow a target to prevent coalescing in certain circumstances also in MachineCSE.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It would of course be nice if the register allocator could undo the contrain+coalescing, i.e. splitting the intervals, and then also relax the register classes if possible. Possibly avoiding spill. No idea if that already is attempted or
even feasible.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">/Björn<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org">llvm-dev-bounces@lists.llvm.org</a>>
<b>On Behalf Of </b>David Callahan via llvm-dev<br>
<b>Sent:</b> den 28 mars 2021 21:05<br>
<b>To:</b> LLVM Dev Mailing list <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> [llvm-dev] Register constraints for implicit register usage<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:8.0pt;line-height:105%"><span style="color:black">I am working on a machine with a special register class which here I will call Xrc containing registers X0..Xk. <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:8.0pt;line-height:105%"><span style="color:black">Some instructions implicitly reference X0. I am modeling this with a pseudo instruction that makes that reference explicit and created a register class X0rc which just
contains X0. This seems to work fine and SelectionDAG introduces copies between the two register classes where I would expect them. <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:8.0pt;line-height:105%"><span style="color:black">The problem I face is that MachineCSE::PerformTrivialCopyPropagation eliminates these copies and effectively changes the register class for the output register of unconstrained
instructions to be X0rc. This is done so aggressively that I end up with multiple overlapping live ranges and so values are constantly being spilled and reloaded. Also, it creates situations where multiple operands of an instruction are bound to this class
and so register allocation fails. <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:8.0pt;line-height:105%"><span style="color:black">What is the preferred way to handle this kind of situation? <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:8.0pt;line-height:105%"><span style="color:black">Thanks <o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:8.0pt;line-height:105%"><span style="color:black">david <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>