From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32225 invoked by alias); 16 Nov 2002 09:06:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 32192 invoked by uid 71); 16 Nov 2002 09:06:01 -0000 Resent-Date: 16 Nov 2002 09:06:01 -0000 Resent-Message-ID: <20021116090601.32190.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, bill@taniwha.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, 162919@bugs.debian.org Received: (qmail 30803 invoked from network); 16 Nov 2002 09:04:32 -0000 Received: from unknown (HELO mail.cs.tu-berlin.de) (130.149.17.13) by sources.redhat.com with SMTP; 16 Nov 2002 09:04:32 -0000 Received: from smile.cs.tu-berlin.de (mail@smile.cs.tu-berlin.de [130.149.19.24]) by mail.cs.tu-berlin.de (8.9.3/8.9.3) with ESMTP id JAA02970; Sat, 16 Nov 2002 09:59:23 +0100 (MET) Received: from doko by smile.cs.tu-berlin.de with local (Exim 3.35 #1 (Debian)) id 18CynT-0001YS-00; Sat, 16 Nov 2002 09:59:23 +0100 Message-Id: Date: Fri, 22 Nov 2002 07:16:00 -0000 From: Matthias Klose Reply-To: 162919@bugs.debian.org To: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org X-Send-Pr-Version: 3.113 X-GNATS-Notify: bill@taniwha.org Subject: optimization/8599: loop unroll bug with -march=k6-3 X-SW-Source: 2002-11/txt/msg00820.txt.bz2 List-Id: >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: