http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46403
Summary: inefficient PRE bloat code size
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
// Example:
int a[100];
int foo(int x, int* y, int z)
{
int m;
if (x)
{
*y = z;
a[x] = z;
}
m = *y; // *y misses often
return m + a[x];
}
with PRE, gcc converts the code to:
int a[100];
int foo(int x, int* y, int z)
{
int m;
if (x)
{
*y = z;
a[x] = z; (1)
tem = *y; (2)
}
else
{
tem = *y; (3)
}
m = tem;
return m + a[x];
}
DUe to may def at (1), *y needs to be reloaded at (2), so hoisting load of *y
to (3) does not reduce any redundency --- but simply bloat up code size.
foo:
.LFB0:
.cfi_startproc
testl %edi, %edi
je .L5
movl %edx, (%rsi)
movslq %edi, %rdi
movl %edx, a(,%rdi,4)
movl (%rsi), %eax
addl %edx, %eax
ret
.p2align 4,,10
.p2align 3
.L5:
movl a(%rip), %edx
movl (%rsi), %eax
addl %edx, %eax
ret
.cfi_endproc
.LFE0:
David