https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61762
Bug ID: 61762
Summary: failure to optimize memcpy from constant string
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: froydnj at gcc dot gnu.org
There's probably a duplicate of this, but GCC HEAD on the following testcase:
unsigned int f()
{
static const char string[] = "Private";
unsigned int priv;
__builtin_memcpy(&priv, &string[0], sizeof(priv));
return priv;
}
produces for x86-64:
f:
.LFB0:
.cfi_startproc
movl _ZZ1fvE6string(%rip), %eax
ret
.cfi_endproc
Compare clang (~3.0) for x86-64:
f:
.Ltmp0:
.cfi_startproc
# BB#0:
movl $1986622032, %eax # imm = 0x76697250
ret