public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/8599: loop unroll bug with -march=k6-3
@ 2002-11-22 7:16 Matthias Klose
0 siblings, 0 replies; only message in thread
From: Matthias Klose @ 2002-11-22 7:16 UTC (permalink / raw)
To: gcc-gnats, debian-gcc
>Number: 8599
>Category: optimization
>Synopsis: loop unroll bug with -march=k6-3
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Sat Nov 16 01:06:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: bill@taniwha.org
>Release: 3.2.1 (Debian) (Debian unstable)
>Organization:
The Debian Project
>Environment:
System: Debian GNU/Linux (unstable)
Architecture: i686
[reproducible with gcc-3.2.1 20021111 and HEAD 20021103]
the following simple code produces a segfault when compiled using gcc
3.2 using the folloing command line:
gcc -march=k6-3 -O3 -ffast-math -funroll-loops -fomit-frame-pointer
-fexpensive-optimizations -fstrict-aliasing -pipe -Wall -Werror
-fno-common -o foo foo.c
---8<---
void *array[4];
int
main ()
{
int i;
for (i = 0; i < sizeof (array) / sizeof (array[0]); i++)
array[i] = 0;
return 0;
}
---8<---
The following is the resulting asm (-S instead of -o foo). Lines
begining with "*" are annotations. Non-useful lines are omitted.
movl $array+4, %eax
movl $array, %edx
cmpl $array+13, %eax
movl $array+12, %ecx
jb .L10
.loc 1 9 0
movl $0, (%edx)
.loc 1 8 0
addl $4, %edx
cmpl %ecx, %edx
ja .L9
.L10:
subl $array-1, %ecx
shrl $4, %ecx
* ^^^ set to 0
.p2align 5,,7
.L28:
.loc 1 9 0
movl $0, (%edx)
movl $0, 4(%edx)
movl $0, 8(%edx)
movl $0, 12(%edx)
.loc 1 8 0
addl $16, %edx
loop .L28
* ^^^ %ecx is 0 for the first pass and thus this loop becomes
* effectively infinite causing %edx to overflow the array.
.L9:
.loc 1 10 0
ret
[snip]
.string "GNU C 3.2.1 20020924 (Debian prerelease)"
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err: uppercase=bad)
||/ Name Version Description
+++-==============-==============-============================================
ii binutils 2.12.90.0.1-5 The GNU assembler, linker and binary utiliti
ii libc6 2.2.5-11.2 GNU C Library: Shared libraries and Timezone
host: i386-linux
Configured with: /home/packages/gcc/3.2/gcc-3.2-3.2.1ds5/src/configure -v --enable-languages=c,c++,java,f77,proto,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux
>Description:
[ Reported to the Debian BTS as report #162919.
Please CC 162919@bugs.debian.org on replies.
Log of report can be found at http://bugs.debian.org/162919 ]
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-11-16 9:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-22 7:16 optimization/8599: loop unroll bug with -march=k6-3 Matthias Klose
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).