This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]