This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Optimizing
- From: Magnus Fromreide <magfr at lysator dot liu dot se>
- To: gcc-help at gcc dot gnu dot org
- Date: Sun, 30 Jan 2011 20:37:16 +0100
- Subject: Optimizing
Consider the following code:
----
#define SRC "Big blob of text goes here"
extern int foo(int, const void*, int);
void f1(void) {
foo(1, SRC, sizeof(SRC) - 1);
}
void f2(void) {
char buf[sizeof(SRC) - 1];
__builtin_memcpy(buf, SRC, sizeof(SRC) - 1);
foo(1, buf, sizeof(SRC) - 1);
}
----
Is it a valid optimization for the compiler to generate the same
instructions for f2 as it generates for f1?
Would it be hard to make GCC do it?
/MF