On 17/12/2010, at 6:34 AM, john skaller wrote:
>
> On 16/12/2010, at 11:56 PM, Paul Steckler wrote:
>
>> On Thu, Dec 16, 2010 at 10:43 PM, john skaller
>> <[email protected]> wrote:
>>> ~/felix>./cack # C version
>>
>> Cack? Such language!
>
>
> Last time I ran this test, Felix beat C by 50%.
Well here's the reason: Felix assembler for rec-call:
movl %r8d, -56(%rbp)
movl %r9d, -64(%rbp)
movl %r10d, -72(%rbp)
movl %r11d, -80(%rbp)
call __ZN6flxusr4testL3ackEii
movl %ebx, %edx
movl -56(%rbp), %r8d
movl -64(%rbp), %r9d
movl -72(%rbp), %r10d
movl -80(%rbp), %r11d
prologue:
LFB2131:
pushq %rbp
LCFI8:
movq %rsp, %rbp
LCFI9:
pushq %r15
LCFI10:
pushq %r14
LCFI11:
pushq %r13
LCFI12:
pushq %r12
LCFI13:
pushq %rbx
LCFI14:
subq $40, %rsp
LCFI15:
C assembler:
leal -1(%r12), %ebx
leal -2(%rax), %esi
movl %r12d, %edi
call _Ack
movl %eax, %esi
movl %ebx, %edi
call _Ack
jmp L29
the important bit is:
_Ack:
LFB6:
pushq %rbp
LCFI0:
movq %rsp, %rbp
LCFI1:
pushq %r12
LCFI2:
pushq %rbx
LCFI3:
So it is pushing 3 machine words (inefficient!).
Interestingly .. it is NOT tail rec optimising.
[The Felix version is tail-rec optimised by Felix]
The Felix version is saving a lot more registers. No idea why.
--
john skaller
[email protected]
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language