This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/35344] New: Loop unswitching to produce perfect loop nest
- From: "xinliangli at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Feb 2008 04:33:05 -0000
- Subject: [Bug middle-end/35344] New: Loop unswitching to produce perfect loop nest
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
GCC loop unswitching is very good -- handles most of the cases I tried. The
only only thing I notice is that the nested for loops in C in the example below
is not converted into a perfect loop nest:
int** p;
int** q;
void foo(int m, int n)
{
int i, j;
for (i = 0; i < m; i++)
{
for (j = 0; j < n ; j++)
{
p[i][j] += q[i][j];
q[i][j] ++;
}
}
}
It is generated into (roughly) the following code by gcc (-O3
-fno-tree-vectorize)
if (m > 0)
{
do
{
if (n > 0 )
{
do
{
p[i][j] += q[i][j];
q[i][j] += 1;
j += 1;
} while ( j < n);
}
i+=1;
} while (i < m);
}
Ideally-- it should be:
if (m > 0)
{
if (n >0)
{
do
{
do
{
....
j++;
} while(...);
i++;
}while (...);
}
// empty loop deleted
}
--
Summary: Loop unswitching to produce perfect loop nest
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: xinliangli at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35344