pi benchmark on ldc and dmd

Walter Bright newshound2 at digitalmars.com
Tue Aug 2 13:38:15 PDT 2011


On 8/2/2011 12:49 PM, Adam D. Ruppe wrote:
> So I'm pretty sure the difference is caused by dmd not using the
> new registers in x64. The other differences look trivial to my
> eyes.

When I compile it, it uses the registers:

L2E:            inc     R11
                 lea     R9D,[00h][RSI*2]
                 mov     R9,R9
                 mov     RCX,R11
                 imul    RCX,RSI
                 mov     RSI,RCX
                 add     RDI,R9
                 add     R8,2
                 mov     RDX,R8
                 imul    RDX,RDI
                 mov     RDI,RDX
                 mov     R10,R8
                 imul    R10,RBX
                 mov     RBX,R10
                 cmp     RDI,RSI
                 jl      L2E
                 lea     RAX,[RCX*2][RCX]
                 add     RAX,RDX
                 mov     -8[RBP],RAX
                 cqo
                 idiv    R10
                 mov     R9,RAX
                 mov     R9,R9
                 mov     RAX,-8[RBP]
                 cqo
                 idiv    R10
                 mov     R12,RDX
                 mov     R12,R12
                 add     R12,RSI
                 cmp     RBX,R12
                 jle     L2E
                 lea     R14,[R14*4][R14]
                 add     R14,R14
                 add     R14,R9
                 mov     R14,R14
                 inc     R13
                 mov     RAX,R13
                 mov     RCX,0Ah
                 cqo
                 idiv    RCX
                 test    RDX,RDX
                 jne     LBD
                 xor     R14,R14
LBD:            cmp     R13,02710h
                 jge     LE3
                 mov     RDX,RBX
                 imul    RDX,R9
                 sub     RDI,RDX
                 imul    R10D,RDI,0Ah
                 mov     RDI,R10
                 imul    R12D,RSI,0Ah
                 mov     RSI,R12
                 jmp       L2E

All I did with your example was replace BigInt with long.


More information about the Digitalmars-d mailing list