This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/17101] New: Opportunity to collapse and eliminate loop
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Aug 2004 14:59:15 -0000
- Subject: [Bug other/17101] New: Opportunity to collapse and eliminate loop
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Description:
A non-optimal code sequence is illustraded. Duplicate using gcc 3.5 and
command line:
gcc -O3 -m64 -funroll-loops -c test.c
Testcase:
int st;
void foo ()
{
int i;
int j;
for (i=0; i < 10; i++)
for (j=0; j < 10; j++)
st = st + j;
}
Assembly:
Code currently generated collapses the outer loop, but not the inner loop:
.foo:
li 0,10
ld 11,.LC0@toc(2)
mtctr 0
.L2:
lwz 9,0(11)
addi 9,9,45
stw 9,0(11)
bdnz .L2
blr
Forward store motion could remove the stw from the loop and allow it to
be collapsed to look like this:
.foo:
ld 11,.LC0@toc(2)
lwz 3,0(11)
addi 9,3,450
stw 9,0(11)
blr
--
Summary: Opportunity to collapse and eliminate loop
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P1
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: steinmtz at us dot ibm dot com
CC: gcc-bugs at gcc dot gnu dot org,steinmtz at us dot ibm
dot com
GCC build triplet: powerpc64-linux
GCC host triplet: powerpc64-linux
GCC target triplet: powerpc64-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17101