I was reading a textbook which describes two way of translating a while loop into machine code:
//jump to middle
goto test;
loop:
body-statement
test:
t = test-expr;
if (t)
goto loop;
and
//guarded do
t = test-expr;
if (!t)
goto done;
loop:
body-statement
t = test-expr;
if (t)
goto loop;
done:
I don't know why using the secoond aproach, the compiler can optimize the initial test?