[Bug middle-end/61762] failure to optimize memcpy from constant string
froydnj at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Aug 1 12:57:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61762
--- Comment #17 from Nathan Froyd <froydnj at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #15)
> Instead aligned the string.
This is kind of unfortunate, as the motivating testcase was something more
like:
...
static const char string[] = "Private";
unsigned int priv, riva, ivat, vate;
memcpy(&priv, &string[0], sizeof(priv));
memcpy(&riva, &string[1], sizeof(riva))
memcpy(&ivat, &string[2], sizeof(ivat));
memcpy(&vate, &string[3], sizeof(vate));
/* proceed to use priv, riva, ivate, vate for comparisons */
So on strict-align targets, even if the source string was aligned (and that has
to be by user-declaration?) we wouldn't catch the latter three?
More information about the Gcc-bugs
mailing list