<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><BR><DIV><DIV>On Mar 25, 2007, at 7:12 AM, Christopher Lamb wrote:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV>While beginning to add vector registers to a back end I came across the following problem: as soon as I define two sets of registers that have a many-to-one mapping the live interval pass appears to double-kill the mapped-onto register. I have the following excerpts from my RegisterInfo.td.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">def V4R0 </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">  </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">: R4v<0 , "V4R0 ", []>, DwarfRegNum<0>;</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;"><BR class="khtml-block-placeholder"></SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">def R0 </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">  </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">: Rg<0 , "R0", [V4R0]>, DwarfRegNum<0>;</SPAN></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">def R1 </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">  </SPAN></FONT><FONT class="Apple-style-span" face="Monaco" size="2"><SPAN class="Apple-style-span" style="font-size: 10px;">: Rg<1 , "R1", [V4R0]>, DwarfRegNum<1>;</SPAN></FONT></DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV>How are R4v and Rg defined?</DIV><DIV><BR><BLOCKQUOTE type="cite"><DIV><BR class="khtml-block-placeholder"></DIV><DIV>when trying to compile:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>define void @_Z3fooii(i32 %a, i32 %b) {</DIV><DIV>entry:</DIV><DIV>        %retval = select i1 false, i32 %a, i32 %b               ; <i32> [#uses=0]</DIV><DIV>        ret void</DIV><DIV>} </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I get this error:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>entry (0x8503b90, LLVM BB @0x8501b00, ID#0):</DIV><DIV>        %reg1024 = ORI %R0, 0</DIV><DIV>        %reg1025 = ORI %R1, 0</DIV><DIV>        RETL</DIV><DIV>Machine Function</DIV><DIV>********** REWRITING TWO-ADDR INSTRS **********</DIV><DIV>********** Function: _Z3fooff</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>********** COMPUTING LIVE INTERVALS **********</DIV><DIV>********** Function: _Z3fooii</DIV><DIV>entry:</DIV><DIV>                livein register: R0 killed +[0,2:0)</DIV><DIV>                livein register: V4R0  killed +[0,2:0)  <=== this is bad</DIV><DIV>                livein register: R1 killed +[0,6:0)</DIV><DIV>                livein register: V4R0  killed +[0,2:1)</DIV><DIV>lib/CodeGen/LiveInterval.cpp:189: failed assertion `B->end <= Start && "Cannot overlap two LiveRanges with differing ValID's" " (did you def the same reg twice in a MachineInstr?)"'</DIV></BLOCKQUOTE><DIV><BR class="khtml-block-placeholder"></DIV>V4R0 should not have been killed twice. The second ORI instruction is the last use of V4R0. Are you adding the correct livein's (just R0 and R1) to the function? </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Can you dump out the machine basic block? It should have an implicit use of V4R0 at first ORI but it should not be marked kill. If it is marked kill, then you need to walk LiveVariables.cpp to find out why.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Evan</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR><BLOCKQUOTE type="cite"><DIV><BR class="khtml-block-placeholder"></DIV><DIV>The problem here is that both R0 and R1 alias to V4R0, but because the live-in interval analysis always starts with the first instruction in the function V4R0 gets the same live range for for both when R0 kills it and when R1, as the first instruction is responsible for the earliest kill in both cases. This presents a problem as the second kill of V4R0 is marked as a second value of V4R0 as well, which causes the assert above to fire.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Either V4R0 is never alive or after R0 is killed V4R0 is only partially dead. This same situation arises even when the parameters are not live-ins to the function, all it takes is two registers which alias a third to have overlapping live ranges, such as when the following code is compiled.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>define void @_Z3foov() {</DIV><DIV>entry:</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">      </SPAN>%tmp1 = tail call float @_Z3onev( )<SPAN class="Apple-tab-span" style="white-space:pre">         </SPAN>; <float> [#uses=2]</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN>%tmp2 = tail call float @_Z3twov( )<SPAN class="Apple-tab-span" style="white-space:pre">         </SPAN>; <float> [#uses=2]</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN>%tmp5 = fcmp olt float %tmp1, %tmp2<SPAN class="Apple-tab-span" style="white-space:pre">         </SPAN>; <i1> [#uses=1]</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">       </SPAN>%retval = select i1 %tmp5, float %tmp1, float %tmp2<SPAN class="Apple-tab-span" style="white-space:pre">         </SPAN>; <float> [#uses=0]</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">    </SPAN>ret void</DIV><DIV>}</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Does the fact that V4R0 is considered live-in mean I need to fix my target code, or does the live interval analysis need fixing to handle this corner case? Any guidance on how to approach this problem would be greatly appreciated.</DIV><DIV><BR class="khtml-block-placeholder"></DIV>Thanks<BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>--</DIV><DIV>Christopher Lamb</DIV><DIV><A href="mailto:christopher.lamb@gmail.com">christopher.lamb@gmail.com</A></DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">LLVM Developers mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</A> <SPAN class="Apple-converted-space">        </SPAN><A href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</A></DIV> </BLOCKQUOTE></DIV><BR></BODY></HTML>