This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/39052] New: writing arrays twice not optimized
- From: "tkoenig at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Feb 2009 00:32:37 -0000
- Subject: [Bug tree-optimization/39052] New: writing arrays twice not optimized
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In the test case below, both stores are done.
The compiler chould eliminate the first loop completely.
$ cat a.c
void foo(int *a, int n)
{
int i;
for (i=0; i<n; i++)
a[i] = 0;
for (i=0; i<n; i++)
a[i] = 1;
}
$ gcc -O3 -S a.c
$ cat a.s
.file "a.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
pushl %ebp
movl %esp, %ebp
movl 12(%ebp), %edx
movl 8(%ebp), %ecx
testl %edx, %edx
jle .L5
xorl %eax, %eax
.p2align 4,,7
.p2align 3
.L3:
movl $0, (%ecx,%eax,4)
addl $1, %eax
cmpl %edx, %eax
jne .L3
xorl %eax, %eax
.p2align 4,,7
.p2align 3
.L4:
movl $1, (%ecx,%eax,4)
addl $1, %eax
cmpl %edx, %eax
jne .L4
.L5:
popl %ebp
ret
.size foo, .-foo
.ident "GCC: (GNU) 4.4.0 20090124 (experimental)"
.section .note.GNU-stack,"",@progbits
--
Summary: writing arrays twice not optimized
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tkoenig at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39052