[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] avr-gcc bug
From: |
Francisco T. A. Silva |
Subject: |
[avr-gcc-list] avr-gcc bug |
Date: |
Sat, 21 Apr 2001 12:41:10 -0300 |
Hi all,
I´ve come upon the following bug.
The code:
int main(void)
{
unsigned int i;
for(i = 31533; i > 0; i--);
}
The compiled code:
.file "bug.c"
.arch avr2
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
_PC_ = 2
; GNU C version 3.1 20010228 (experimental) (avr)
; compiled by GNU C version egcs-2.91.66 19990314/Linux (egcs-1.
1.2 release).
; options passed: -lang-c -D__GNUC__=3 -D__GNUC_MINOR__=1
; -D__GNUC_PATCHLEVEL__=0 -DAVR -D__AVR__ -D__AVR -D__OPTIMIZE_SIZE__
; -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -D__AVR_ARCH__=2
; -D__SIZE_TYPE__=unsigned int -D__PTRDIFF_TYPE__=int -D__INT_MAX__=32767
; -Os -fverbose-asm
; options enabled: -fdefer-pop -fomit-frame-pointer
; -foptimize-sibling-calls -fcse-follow-jumps -fcse-skip-blocks
; -fexpensive-optimizations -fthread-jumps -fstrength-reduce -fpeephole
; -fforce-mem -ffunction-cse -finline -fkeep-static-consts -fcaller-
saves
; -freg-struct-return -fgcse -frerun-cse-after-loop -frerun-loop-opt
; -fdelete-null-pointer-checks -fsched-interblock -fsched-spec
; -fbranch-count-reg -fnew-exceptions -fsjlj-exceptions -freorder-
blocks
; -fcommon -fverbose-asm -fgnu-linker -fregmove -foptimize-register-
move
; -fargument-alias -fstrict-aliasing -fident -fpeephole2
; -fguess-branch-probability -fmath-errno -minit-stack=__stack
-mmcu=avr2
gcc2_compiled.:
.text
.global main
.type main,@function
main:
/* prologue: frame size=0 */
ldi r28,lo8(__stack - 0)
ldi r29,hi8(__stack - 0)
out __SP_H__,r29
out __SP_L__,r28
/* prologue end (size=4) */
ldi r24,lo8(31524) <<<<<<<<<<<<<<<<< wrong value (should be 31533)
ldi r25,hi8(31524)
.L5:
sbiw r24,12 <<<<<<<<<<<<<<<<< wrong (should be sbiw r24,1)
brne .L5
/* epilogue: frame size=0 */
__stop_progIi__:
rjmp __stop_progIi__
/* epilogue end (size=1) */
/* function main size 10 (5) */
.Lfe1:
.size main,.Lfe1-main
/* File bug.c: code 10 = 0x000a ( 5), prologues 4, epilogues
1 */
This bug apears with -Os, -O2, -O3. It seems from now on I´m restricted
to -O :(.
Regards,
--
Francisco
- [avr-gcc-list] avr-gcc bug,
Francisco T. A. Silva <=