Sent from my iPhone
On Feb 27, 2010, at 10:17 AM, "Daniel R. Grayson" <d...@math.uiuc.edu>
wrote:
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.
I can think of one case where this is not true. Sibcalling where
arguments are the same size and the order are different or just
different in general.
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.