Skip to contentSkip to conversation

Faster generic_fls

RFC PATCH Chuck Ebbert 2 participants 2 messages May 2, 2003

lore
Share & tools
lore
#0 lore raw
Quoted 3 lines · David S. Miller

I know you think GCC is a pile of dogshit, in many ways I do too, but I think it's just as important to point out the good parts where they exist.

GCC is the strangest combination of utterly brilliant and brain-dead
stupid that I've ever seen... I've seen it do tail merges that took my breath away, followed by this:

mov <mem1>,eax
mov eax,<mem2>
mov <mem1>,eax ; eax already contains mem1 you stupid compiler
ret

------
Chuck

#1 lore raw
Quoted 8 lines · Chuck Ebbert

GCC is the strangest combination of utterly brilliant and brain-dead
stupid that I've ever seen... I've seen it do tail merges that took my breath away, followed by this:

mov <mem1>,eax
mov eax,<mem2>
mov <mem1>,eax ; eax already contains mem1 you stupid compiler
ret

Not necessarily if mem2 == mem1 + 2. Consider this code:

        #include <string.h>
        int f(char* a, char* b)
        {
            int t;
            memcpy(&t, a, sizeof(int));
            memcpy(b, &t, sizeof(int));
            memcpy(&t, a, sizeof(int));
            return t;
        }

"gcc -O2 -Wall -S test.c -fomit-frame-pointer" correctly generates:

f:

        movl    4(%esp), %ecx
        movl    (%ecx), %eax
        movl    8(%esp), %edx
        movl    %eax, (%edx)
        movl    (%ecx), %eax

ret

Signature · 2 lines
Peter Osterlund - [email protected]
http://w1.894.telia.com/~u89404340