I wonder whether there is a plan to optimize code such as this:

extern int ffff(const int x);
void hhhh() {
     ffff(444);
     ffff(444);
     }

by not pushing the constant argument twice.  It seems safe to do so,
because the function called will not modify its argument on the stack.
The experiment I did with gcc 4.4.1 -O3 indicates this is not currently
being done, with this result:

        movl    $444, (%esp)
        call    ffff
        movl    $444, (%esp)
        call    ffff


The application I have in mind is putting a pointer to thread local
storage as the last argument for many functions.

Reply via email to