[Issue 6658] Slow short array equality

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Mar 31 03:29:17 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=6658



--- Comment #1 from bearophile_hugs at eml.cc 2013-03-31 03:29:16 PDT ---
After closing Issue 9477  the situation is changed a little.

On the same PC with DMD 2.063alpha the run-time with eq2() is 2.04 seconds and
the run-time with eq1() is 6.37 seconds (3.12X).

The asm produced by dmd (-O -release -inline -noboundscheck) for the two
versions:


eq1:
        push EAX
        mov ECX, 0Ch
        push ESI
        mov ESI, 0Ch[ESP]
        push EDI
        mov EDI, EAX
        xor EAX, EAX
        rep
        cmpsb
        je  L19
        sbb EAX, EAX
        sbb EAX, 0FFFFFFFFh
L19:    neg EAX
        sbb EAX, EAX
        inc EAX
        pop EDI
        pop ESI
        pop ECX
        ret 4


eq2:
        push EBX
        mov EDX, EAX
        mov ECX, 8[ESP]
        xor EBX, EBX
L9:     mov EAX, [EBX*4][ECX]
        cmp EAX, [EBX*4][EDX]
        je  L17
        pop EBX
        xor EAX, EAX
        ret 4
L17:    inc EBX
        cmp EBX, 3
        jb  L9
        pop EBX
        mov EAX, 1
        ret 4


Is cmpsb efficient on modern CPUs? Maybe the answer is negative:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list