<font face="Calibri, sans-serif"><font style="FONT-SIZE: 11pt" size="2">Hi</font></font> 
<div style="MARGIN-BOTTOM: 0cm"><font face="Calibri, sans-serif"><font style="FONT-SIZE: 11pt" size="2">I'm following the excellent Kaleidoscope tutorial to learn how to build an interpreter using LLVM. Apologize if this list is not the best place to post beginner's questions. In Kaleidoscope 2.7 when I run </font></font></div>

<div style="MARGIN-BOTTOM: 0cm"><font face="Courier New, monospace"><font size="2"></font></font> </div>
<div style="MARGIN-BOTTOM: 0cm"><font face="Courier New, monospace"><font size="2">def binary : 1 (x y) y;</font></font></div>
<div style="MARGIN-BOTTOM: 0cm"><font face="Courier New, monospace"><font size="2"></font></font> </div>
<div style="MARGIN-BOTTOM: 0cm"><font face="Courier New, monospace"><font size="2">def testfor (x)</font></font></div>
<div style="MARGIN-BOTTOM: 0cm"><font face="Courier New, monospace"><font size="2">(for c = 1, c<2 in</font></font></div>
<div style="MARGIN-BOTTOM: 0cm"><font face="Courier New, monospace"><font size="2">x = x +1 ) :</font></font></div>
<div style="MARGIN-BOTTOM: 0cm"><font face="Courier New, monospace"><font size="2">x;</font></font></div>
<div style="MARGIN-BOTTOM: 0cm"><font face="Courier New, monospace"><font size="2"></font></font> </div>
<div style="MARGIN-BOTTOM: 0cm"><font face="Courier New, monospace"><font size="2">testfor(1)</font></font></div>
<div style="MARGIN-BOTTOM: 0cm"><font face="Calibri, sans-serif"><font style="FONT-SIZE: 11pt" size="2"></font></font> </div>
<div style="MARGIN-BOTTOM: 0cm"><font face="Calibri, sans-serif"><font style="FONT-SIZE: 11pt" size="2">unexpectadly get 3.000000 instead of 2.000000. This happens, I believe, because the instruction</font></font></div>
<div style="MARGIN-BOTTOM: 0cm"><font color="#000000"><font face="Courier New, monospace"><font size="2"></font></font></font> </div>
<div style="MARGIN-BOTTOM: 0cm"><font color="#000000"><font face="Courier New, monospace"><font size="2">%faddtmp = fadd </font></font></font><font color="#7f0055"><font face="Courier New, monospace"><font size="2"><b>double</b></font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="2"><span style="FONT-WEIGHT: normal"> %x1.0, 1.000000e+000 ; <</span></font></font></font><font color="#7f0055"><font face="Courier New, monospace"><font size="2"><b>double</b></font></font></font><font color="#000000"><font face="Courier New, monospace"><font size="2"><span style="FONT-WEIGHT: normal">> [#uses=2]</span></font></font></font><font color="#000000"><font face="Times New Roman, serif"><font size="3"><span style="FONT-WEIGHT: normal"> </span></font></font></font></div>

<div style="MARGIN-BOTTOM: 0cm"><font color="#000000"><font face="Times New Roman, serif"><font size="3"><span style="FONT-WEIGHT: normal"></span></font></font></font><font color="#000000"><font face="Calibri, sans-serif"><font style="FONT-SIZE: 11pt" size="2">is being generated before</font></font></font></div>

<div style="MARGIN-BOTTOM: 0cm"><font face="Courier New, monospace"><font size="2"><font color="#000000"><span style="FONT-WEIGHT: normal">%ltcmptmp = fcmp ult </span></font><font color="#7f0055"><b>double</b></font><font color="#000000"><span style="FONT-WEIGHT: normal"> %c.0, 2.000000e+000 ; <i1> [#uses=1]</span></font></font></font></div>

<div style="MARGIN-BOTTOM: 0cm"><font face="Courier New, monospace"><font size="2"><font color="#000000"><span style="FONT-WEIGHT: normal"></span></font></font></font><font face="Courier New, monospace"><font size="2">br i1 %ltcmptmp, label %loop, label %afterloop</font></font></div>

<div style="MARGIN-BOTTOM: 0cm"> </div>
<div style="MARGIN-BOTTOM: 0cm"><font color="#000000"><font face="Calibri, sans-serif"><font style="FONT-SIZE: 11pt" size="2">and therefore the loop body is emited first and only afterwards we determine whether the loop should exit. I was wondering if this is the intended behaviour, since the fibi(x) example in chapter 7 uses this extra loop to return correct values for fibonacci numbers, or perhaps a known bug in Kaleidoscope.</font></font></font></div>

<div style="MARGIN-BOTTOM: 0cm; FONT-WEIGHT: normal"><font color="#000000"><font face="Calibri, sans-serif"><font style="FONT-SIZE: 11pt" size="2"></font></font></font> </div>
<div style="MARGIN-BOTTOM: 0cm; FONT-WEIGHT: normal"><font color="#000000"><font face="Calibri, sans-serif"><font style="FONT-SIZE: 11pt" size="2">Any advice would be much apreciated</font></font></font></div>
<div style="MARGIN-BOTTOM: 0cm; FONT-WEIGHT: normal"><font color="#000000"><font face="Calibri, sans-serif"><font style="FONT-SIZE: 11pt" size="2">Anton</font></font></font></div>
<p style="MARGIN-TOP: 0.18cm; MARGIN-BOTTOM: 0.18cm; FONT-WEIGHT: normal">
<div> </div>
<div> </div></p>