[Bug target/70079] New: missed constant propagation in memcpy expansion
bonzini at gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Mar 4 11:10:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70079
Bug ID: 70079
Summary: missed constant propagation in memcpy expansion
Product: gcc
Version: 5.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: bonzini at gnu dot org
Target Milestone: ---
int f(char *restrict a, const char *restrict b)
{
__builtin_memcpy(a, b, 512);
}
$ gcc f.c -O2 - -o f.s
includes the following code:
movq %rdi, %rcx
leaq 8(%rdi), %rdi
andq $-8, %rdi ;; 1
subq %rdi, %rcx ;; 2
subq %rcx, %rsi ;; 3
addl $512, %ecx ;; 4
shrl $3, %ecx ;; 5
At 1, rdi = (a + 8) & ~7 = a & ~7 + 8 = a + 8 - (a & 7)
At 2, rcx = a - rdi = a - a - 8 + (a & 7) = (a & 7) - 8
At 3, rsi = b - (a & 7) + 8
At 4, rcx = (a & 7) + 504, which is between 504 and 511
At 5, rcx is always 31.
Not sure how to fix it in RTL optimizers, so I'm leaving this in the target
component for a backend-specific fix.
More information about the Gcc-bugs
mailing list