Chuck Ebbert <76306.1226@compuserve.com> writes:
> 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
-- Peter Osterlund - petero2@telia.com http://w1.894.telia.com/~u89404340 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Wed May 07 2003 - 22:00:15 EST