I often like to look through the generated assembly code - it helps me be
sure that the code will do what I want, and to be sure that I am not
accidently doing something very inefficiently.  One thing I notice is that
the way code for if-else blocks is generated seems a bit odd.  Consider the
code:
    if (x) doTrue() else doFalse();
    doTheRest();

This compiles roughly to:
    if (!x) goto L1
    doTrue();
L2:
    doTheRest();
    ret
L1:
    doFalse()
    goto L2

I would have thought the obvious code would be:
    if (!x) goto L1
    doTrue();
    goto L2
L1:
    doFalse();
L2:
    doTheRest();
    ret


Is there any reason for generating the first form?  It means one less jump
for the true case, but one more jump for the false case.  It also makes it a
lot more difficult to follow the generated assembly code.



mvh.

David





Reply via email to