http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46281
Summary: Inefficient unswitching (too many copies)
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: [email protected]
ReportedBy: [email protected]
Compiling the following program with -O3:
extern int gen_int(int);
extern void ref_int_p(int*);
void kernel3 ()
{
int i;
int j;
int k;
int l;
int m;
int a[200];
j = gen_int (0);
k = gen_int (0);
l = gen_int (0);
m = gen_int (0);
for (i = 0; i < 200; i++)
{
if (j < k || j < l || j < m ) // || j << 3 || k << 4)
a[i] = 1;
else
a[i] -= j;
}
ref_int_p (&a[0]);
return;
}
Gcc unswitches the loop, but generate three copies of the loop -- it should
only generate 2 copies.
LLVM correctly generates two copies.
David