|Acceptable C optimizations? firstname.lastname@example.org (Ed Finch) (1994-04-27)|
|Re: Acceptable C optimizations? email@example.com (1994-04-29)|
|From:||Ed Finch <firstname.lastname@example.org>|
|Keywords:||C, optimize, question, comment|
|Date:||Wed, 27 Apr 1994 04:11:57 GMT|
I have a question on possible optimizations:
When, if at all, is it acceptable for a compiler to perform the following
In C, strcpy() can be used as "strcpy(x,"HelloWorld");". Rather than emit
a call to strcpy, why not simply emit the machine instructions directly?
I.e., something like a 'move bytes' instruction - move dest to src
for 11 bytes.
Similarly, calls like memset(x,0,sizeof(x)); could also be handled.
[My reading of ANSI says that if a program includes the header that defines
the functions, <string.h> in these cases, the names are reserved and the
compiler can generate any old code it wants that gets the correct effect.
In fact, inlining these functions is quite common because it gives you
great Dhrystone numbers. -John]
Return to the
Search the comp.compilers archives again.