factorial: let's get ahead of jhc! :)

Simon Marlow simonmarhaskell at gmail.com
Wed Mar 1 07:11:53 EST 2006


FWIW, here's the inner loop of the accumulating parameter factorial 
compiled with yesterday's HEAD on x86_64, via C:

Fac_zdwfac_info:
         movq    %rsi, %rax
         testq   %rsi, %rsi
         jne     .L4
         movq    %rdi, %rbx
         jmp     *(%rbp)
.L4:
         leaq    -1(%rsi), %rsi
         imulq   %rax, %rdi
         jmp     Fac_zdwfac_info

It's not perfect, but note the absence of memory operations.

The NCG version is similar, but has a couple of extra reg-to-reg moves 
(we need to beef up the NCG optimisations a bit).

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list