<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=utf-8">
<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;}
@font-face
        {font-family:"Intel Clear";
        panose-1:2 11 6 4 2 2 3 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Intel Clear",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">Thanks Tim and Craig. I tried both of your suggestions, and both generate the correct machine code for the test examples I have written. Looking at the documentation for SUBREG_TO_REG:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">  /// SUBREG_TO_REG - This instruction is similar to INSERT_SUBREG except that<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">  /// the first operand is an immediate integer constant. This constant is<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">  /// often zero, because it is commonly used to assert that the instruction<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">  /// defining the register implicitly clears the high bits.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">So I think I agree with Craig that the more natural solution is to stick with INSERT_SUBREG.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">Thanks!!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif">Scott<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Intel Clear",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><b>From:</b> Craig Topper <craig.topper@gmail.com> <br>
<b>Sent:</b> Wednesday, January 20, 2021 9:14 AM<br>
<b>To:</b> Tim Northover <t.p.northover@gmail.com><br>
<b>Cc:</b> Constable, Scott D <scott.d.constable@intel.com>; llvm-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [llvm-dev] [X86] Is it possible to implicitly promote a virtual subregister to a super?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">If there's no guarantee of a value for the upper bits don't you want INSERT_SUBREG? SUBREG_TO_REG says the upper bits are 0(or whatever the immediate says). Not that I've ever found a place that checks it.<o:p></o:p></p>
<div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">~Craig<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, Jan 20, 2021 at 9:09 AM Tim Northover via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">On Wed, 20 Jan 2021 at 16:30, Constable, Scott D<br>
<<a href="mailto:scott.d.constable@intel.com" target="_blank">scott.d.constable@intel.com</a>> wrote:<br>
> The actual implementation I'm doing is a bit more complex than the example I provided for illustrative purposes. In my case, I don't need to care about the upper bits at all.<br>
<br>
OK, in that case I think SUBREG_TO_REG is what you want. Something like<br>
<br>
BuildMI(MBB, InsertPt, Loc, TII->get(X86::SUBREG_TO_REG), ExtendedReg)<br>
    .addImm(0) // Never been entirely sure what this was here for.<br>
It's always 0.<br>
    .addReg(NarrowReg)<br>
    .addImm(X86::sub_16bit);<br>
<br>
then use ExtendedReg (a GR32 vreg) in the compare.<br>
<br>
Cheers.<br>
<br>
Tim.<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">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>