Useless %esp manipulation; omitting "l" suffix in assembly output; getting the address of a label from another function.
Richard Henderson
rth@redhat.com
Fri Apr 11 00:27:00 GMT 2003
On Thu, Apr 10, 2003 at 05:50:00PM -0500, Mark J Roberts wrote:
> struct x { int a, b, c, d; };
>
> struct x zook(void)
> {
> struct x x = {0, 1, 2, 3};
> return x;
> }
>
> gcc -S -O2 -fomit-frame-pointer -march=athlon-xp test.c
>
> .file "test.c"
> .text
> .p2align 4,,15
> globl zook
> .type zook, @function
> zook:
> subl $28, %esp
> movl 32(%esp), %eax
> movl $0, (%eax)
> movl $1, 4(%eax)
> movl $2, 8(%eax)
> movl $3, 12(%eax)
> addl $28, %esp
> ret $4
> .size zook, .-zook
> .ident "GCC: (GNU) 3.4 20030410 (experimental)"
>
> and you get code that uselessly moves %esp.
This should be fixed by tree-ssa stuff, but can't be done
otherwise. We committed too early to putting "x" on the
stack.
> 1) Output "mov" instead of "movl", etc, since gas doesn't require
> the suffix and it's easier to read the code when they are omitted.
I disagree about legibility. And, you've no idea how this
affects various legacy assemblers.
> 2) Given code like
>
> void process(void *addr)
> {
> goto *addr;
> l1:
> l2: something goes here
> l3:
> l4:
> }
>
> where you're trying to optimize some code by saving the address of a
> label and using it next time the function is called, provide some
> way to get the address of the label from another function (useful
> for initializing addr the first time). Ie,
>
> void setup(struct state *s)
> {
> s->addr = process.l1;
> }
>
> or whatever.
No thanks. There are several other solutions you can use here.
r~
More information about the Gcc
mailing list