<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hello,</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
We have a problem in our target that occurs during the "detect dead lanes" pass. I think it stems from how we've defined our register classes and/or registers and/or subregisters. SubRegLiveness is enabled on our target.<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Taking a simple example where A registers have two low/high "half" subregisters, and B registers have four "quarter" subregisters. They can both be used interchangeably by certain instructions, so we stick them into one register class.<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<blockquote style="margin-top: 0px; margin-bottom: 0px;">
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;">foreach i = 0-31 in {</span><br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;">  def A#i : Reg<[ALo, AHi], [ALoSRIdx, AHiSRIdx]>;</span></div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;">  def B#i : Reg<[BQ0, BQ1, BQ2, BQ3], [BQ0SRIdx, BQ1SRIdx, BQ2SRIdx, BQ3SRIdx]>;</span><br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;">}</span><br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;">def ARegs </span><span id="��" style="font-family: Consolas, Courier, monospace;">: RegisterClass<...(sequence "A%u", 0, 31)>;</span><span><br>
</span></div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span id="��" style="font-family: Consolas, Courier, monospace;">def BRegs : RegisterClass<</span><span><span style="font-family: Consolas, Courier, monospace;">...(sequence "B%u", 0, 31)>;</span></span><br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;">def SuperRegs : RegisterClass<...(add ARegs, BRegs)>;</span></div>
</blockquote>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The following input MIR copies from an A to a B through the intermediary superclass:<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;">    %0:aregs = COPY $a0</span><span><br>
</span>
<div><span style="font-family: Consolas, Courier, monospace;">    %1:superregs = COPY %0</span><br>
</div>
<div><span style="font-family: Consolas, Courier, monospace;">    %2:bregs = COPY %1</span><br>
</div>
<span></span><br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
After dead lanes, we get:</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: Consolas, Courier, monospace;">    dead %0:aregs = COPY $a0</span><span><br>
</span>
<div><span style="font-family: Consolas, Courier, monospace;">    %1:superregs = COPY undef %0</span><br>
</div>
<span style="font-family: Consolas, Courier, monospace;">    %2:bregs = COPY undef %1</span></div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>I think that it's because the subregister lanes of aregs and bregs don't overlap, so it decides that %0 defines no used lanes? If the middle COPY is removed, so we have a copy directly from aregs to bregs, then dead-lanes detects a copy between incompatible
 classes and does not produce the incorrect code.<br>
</span></div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I haven't found any documentation about how registers and register classes should (or, should not) be defined and the implicit restrictions placed upon them. Does anyone more familiar with the register and sub-register code know more about that we're doing
 wrong? I believe that whatever is happening, it should be documented.<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
This happens in 4.01 and 7.1.0. I'm afraid I haven't tried anything more recent than that.<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks in advance,<br>
</div>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<span style="font-size:10pt"></span>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<span style="font-size:10pt"></span>
<p style="margin-top: 0px; margin-bottom: 0px;margin-top:0; margin-bottom:0"><span id="ms-rterangepaste-start"></span></p>
<span style="font-size:10pt"></span>
<pre class="moz-signature" cols="72"><span style="font-size:10pt">Fraser</span><span style="font-size:10pt"></span><span style="font-size:10pt"></span></pre>
<p style="margin-top: 0px; margin-bottom: 0px;"></p>
<span style="font-size:10pt"></span></div>
<span style="font-size:10pt"></span></div>
</div>
</body>
</html>