<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 8, 2010, at 12:25 AM, Félix Cloutier wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">It's past 3 AM here, so maybe I really shouldn't be answering in this state of awakeness. However, what I understand from your example is that loops with counters must be entered from another block in order to use the phi instruction correctly, not that it should be invalid to branch to the entry block.<div><br></div><div>It seems to me that it makes sense to go back to the entry point if looping is not directed by a counter. Consider the following snippet of invalid IR:<div><br></div><div><div><font class="Apple-style-span" face="Menlo">define i32 @foo() nounwind {</font></div><div><font class="Apple-style-span" face="Menlo">entry:</font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="Menlo">     </font></span><font class="Apple-style-span" face="Menlo">%time = call i32 @time(i32* null) nounwind</font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="Menlo">     </font></span><font class="Apple-style-span" face="Menlo">%cmp = icmp eq i32 %time, 1234567890</font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="Menlo">   </font></span><font class="Apple-style-span" face="Menlo">br i1 %cmp, label %exit, label %entry</font></div><div><font class="Apple-style-span" face="Menlo">exit:</font></div><div><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" face="Menlo">   </font></span><font class="Apple-style-span" face="Menlo">ret i32 0</font></div><div><font class="Apple-style-span" face="Menlo">}</font></div><div><font class="Apple-style-span" face="Menlo"><br></font></div><div><font class="Apple-style-span" face="Menlo">declare i32 @time(i32*) nounwind</font></div><div><br></div><div>Is the problem really inherent to the entry block, or is it rather inherent to the use of the phi instruction from the entry block?</div></div></div></div></blockquote><div><br></div>It's inherent to the entry block.  A lot of things are special about the entry block;  allowing branches to it would make everything else more complicated.</div><div><br></div><div>John.</div></body></html>