public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Optimizing
@ 2011-01-30 20:18 Magnus Fromreide
  2011-01-30 20:24 ` Optimizing Kalle Olavi Niemitalo
  0 siblings, 1 reply; 4+ messages in thread
From: Magnus Fromreide @ 2011-01-30 20:18 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-30 21:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-30 20:18 Optimizing Magnus Fromreide
2011-01-30 20:24 ` Optimizing Kalle Olavi Niemitalo
2011-01-30 20:55   ` Optimizing Enrico Weigelt
2011-01-30 21:02     ` Optimizing Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).