Bulat Ziganshin wrote:

i prefer to see the asm code. this may be because of better high-level
optimization strategies (reusing fib values). the scheme about i say
will combine advantages of both worlds
no strategies, plain exponential algorithm,

ocaml:
<excerpt>
_camlFibo__fib_57:
   sub    esp, 8
L101:
   cmp    eax, 5
   jge    L100
   mov    eax, 3
   add    esp, 8
   ret
L100:
   mov    DWORD PTR 0[esp], eax
   add    eax, -4
   call    _camlFibo__fib_57
L102:
   mov    DWORD PTR 4[esp], eax
   mov    eax, DWORD PTR 0[esp]
   add    eax, -2
   call    _camlFibo__fib_57
L103:
   mov    ebx, DWORD PTR 4[esp]
   add    eax, ebx
   dec    eax
   add    esp, 8
   ret
</excerpt>

visual C++ 7.1 (next fastest):
<excerpt>
_fib    PROC NEAR
   push    esi
   mov    esi, DWORD PTR 8[esp]
   cmp    esi, 2
   jge    SHORT $L945
   mov    eax, 1
   pop    esi
   ret    0
$L945:
   lea    eax, DWORD PTR [esi-2]
   push    edi
   push    eax
   call    _fib
   dec    esi
   push    esi
   mov    edi, eax
   call    _fib
   add    esp, 8
   add    eax, edi
   pop    edi
   pop    esi
   ret    0
_fib    ENDP
</excerpt>

also, Clean is *EXACTLY* in line with ocaml. This is interesting, because Clean is so much similar to Haskell.
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to