This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: optimization/7799: [3.2/3.3 regression] Loop bug with optimization flag -Os in gcc
- From: "Christian Ehrhardt" <ehrhardt at mathematik dot uni-ulm dot de>
- To: nejataydin at superonline dot com, gcc-gnats at gcc dot gnu dot org, gcc at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, nobody at gcc dot gnu dot org
- Date: Fri, 13 Dec 2002 14:36:26 +0100
- Subject: Re: optimization/7799: [3.2/3.3 regression] Loop bug with optimization flag -Os in gcc
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7799
Hi,
this PR is about the following code snippet that is miscompiled with -Os
void fill (int* p, int* q[10])
{
int i;
for (i = 0; i < 10; i++)
*q++ = &p[i];
}
The asm-Code is this:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
movl 12(%ebp), %edx
leal 36(%eax), %ecx
.L6:
movl %eax, (%edx)
addl $4, %eax
addl $4, %edx
cmpl %ecx, %eax
jle .L6
popl %ebp
ret
This code roughly corresponds to the following C-Code:
void fill (int * p, int *q[10])
{
int ecx = (int)p + 9;
do {
*q = p; p++; q++;
} while ((int)p <= ecx);
}
This transformation is IMHO illegal because there is no way to make the
comparison in general equivialent to that in the original for loop.
If p is initially 0x7ffffffc the comparison must be treated as unsigned,
however, if p is initially 0xfffffffc the comparison must be treated as
signed.
regards Christian
--
THAT'S ALL FOLKS!