public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: gumo@lucifer.kgt.bme.hu
To: gcc-gnats@gcc.gnu.org
Subject: optimization/10620: for(i=25000;i;i--) {} generates wrong assembly source in avr-gcc with -O2
Date: Sun, 04 May 2003 14:26:00 -0000	[thread overview]
Message-ID: <20030504142228.16846.qmail@sources.redhat.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1083 bytes --]


>Number:         10620
>Category:       optimization
>Synopsis:       for(i=25000;i;i--) {} generates wrong assembly source in avr-gcc with -O2
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Sun May 04 14:26:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Endre Nagy
>Release:        gcc version 3.3 20030421 (prerelease)
>Organization:
>Environment:
Win32 -> atmel avr crosscompiler
>Description:
C code: for(i=25000;i;i--) {}
faulty machine code (it would be OK for i-=25):
ldi r18,lo8(25000)
ldi r19,hi8(25000)
.L10:·
        subi r18,lo8(-(-25))
        sbci r19,hi8(-(-25))
        brne .L10·

C code: for(i=35000;i;i--) {}
correct machine code (only initial value of i has changed):
ldi r18,lo8(-30536)
ldi r19,hi8(-30536)
.L10:
	subi r18,lo8(-(-1))
	sbci r19,hi8(-(-1))
	brne .L10

commandline:
avr-gcc -g -Wall -O2 -mmcu=at90s8515 -S -o os8515.S os8515.c
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2003-05-04 14:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-04 14:26 gumo [this message]
2003-05-09  8:16 Dara Hazeghi
2003-05-09  8:56 Nagy Endre

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=20030504142228.16846.qmail@sources.redhat.com \
    --to=gumo@lucifer.kgt.bme.hu \
    --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).