Quoting Andrew Pinski <[email protected]>:
Sent from my iPhone On Feb 27, 2010, at 10:17 AM, "Daniel R. Grayson" <[email protected]> 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.
In that case, the sibcall optimization really actually goes against the function declaration. It's basically an ABI decision if we consider that valid. If it's not valid for a target, then the push optimization should be safe; this might be indicated by a target hook.
