public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Matthias Klose <doko@smile.cs.tu-berlin.de>
To: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org
Subject: optimization/8599: loop unroll bug with -march=k6-3
Date: Fri, 22 Nov 2002 07:16:00 -0000	[thread overview]
Message-ID: <E18CynT-0001YS-00@smile.cs.tu-berlin.de> (raw)


>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:


                 reply	other threads:[~2002-11-16  9:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E18CynT-0001YS-00@smile.cs.tu-berlin.de \
    --to=doko@smile.cs.tu-berlin.de \
    --cc=162919@bugs.debian.org \
    --cc=debian-gcc@lists.debian.org \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).