This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

optimization/10620: for(i=25000;i;i--) {} generates wrong assembly source in avr-gcc with -O2


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]