This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/39633] [avr] loop bug
- From: "gjl at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 9 Jul 2011 15:51:02 +0000
- Subject: [Bug target/39633] [avr] loop bug
- Auto-submitted: auto-generated
- References: <bug-39633-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39633
Georg-Johann Lay <gjl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Last reconfirmed|2009-08-17 12:12:00 |2010-07-09 12:12
CC|avr at gjlay dot de |gjl at gcc dot gnu.org
Known to fail| |4.5.2, 4.6.1
--- Comment #6 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-07-09 15:48:55 UTC ---
I confirm it on 4.6.1, 4.5.0 and 4.5.2 (-fno-strict-overflow does not help)
I see the bug only for -O1 (in which case g_52=1) and not for other
optimization levels (in which case g_52=5).
The bug disappears if l_116 in func_1 is declared as uint32_t instead of
uint64_t.
In 4.6.1, g_52 is as follows:
-Os -fsplit-wide-types: 5
-Os -fno-split-wide-types: 1
This remains after adding the no_inline attribute to safe_add_func_int8_t_s_s
that gets compiler to:
safe_add_func_int8_t_s_s.constprop.0:
cpi r24,lo8(125) ; _si1, ; 6 *cmpqi/3
brge .L2 ; , ; 7 branch
subi r24,lo8(-(3)) ; _si1, ; 9 addqi3/2
.L2:
ret ; 28 return
With -Os -fsplit-wide-types, the compile of func_1 is(g_52=5 ok):
func_1:
/* prologue: function */
ldi r24,lo8(0) ; l_116, ; 3 *movqi/1
.L4:
lds r25,g_52 ; tmp52, g_52 ; 15 *movqi/4
subi r25,lo8(-(1)) ; tmp52, ; 16 addqi3/2
sts g_52,r25 ; g_52, tmp52 ; 17 *movqi/3
rcall safe_add_func_int8_t_s_s.constprop.0 ; 20 call_value_insn/3
sbrc r24,7 ; l_116, ; 99 *sbrx_branchhi
rjmp .L3 ;
cpi r24,lo8(13) ; l_116, ; 60 *cmpqi/3
brlo .L4 ; , ; 61 branch
.L3:
ret ; 98 return
With -Os -fno-split-wide-types, the compile of func_1 is (g_52=1 wrong):
func_1:
push r8 ; ; 90 *pushqi/1
push r9 ; ; 91 *pushqi/1
push r10 ; ; 92 *pushqi/1
push r11 ; ; 93 *pushqi/1
push r12 ; ; 94 *pushqi/1
push r13 ; ; 95 *pushqi/1
push r14 ; ; 96 *pushqi/1
push r15 ; ; 97 *pushqi/1
/* prologue: function */
clr r8 ; l_116 ; 3 *movqi/1
.L4:
lds r24,g_52 ; tmp52, g_52 ; 15 *movqi/4
subi r24,lo8(-(1)) ; tmp52, ; 16 addqi3/2= 1]
sts g_52,r24 ; g_52, tmp52 ; 17 *movqi/3
mov r24,r8 ; , l_116 ; 19 *movqi/1
rcall safe_add_func_int8_t_s_s.constprop.0 ; 20 call_value_insn/3
mov r8,r24 ; l_116, D.2168 ; 22 *movqi/1
lsl r24 ; tmp54 ; 23 ashrqi3/5
sbc r24,r24 ; tmp54
brne .L3 ; , ; 33 branch
tst r24 ; l_116 ; 36 *cmpqi/1
brne .L3 ; , ; 37 branch
tst r24 ; l_116 ; 40 *cmpqi/1
brne .L3 ; , ; 41 branch
tst r24 ; l_116 ; 44 *cmpqi/1
brne .L3 ; , ; 45 branch
tst r24 ; l_116 ; 48 *cmpqi/1
brne .L3 ; , ; 49 branch
tst r24 ; l_116 ; 52 *cmpqi/1
brne .L3 ; , ; 53 branch
tst r24 ; l_116 ; 56 *cmpqi/1
brne .L3 ; , ; 57 branch
ldi r24,lo8(12) ; , ; 89 *movqi/2
cp r24,r8 ; , l_116 ; 60 *cmpqi/2
brsh .L4 ; , ; 61 branch
.L3:
/* epilogue start */
pop r15 ; ; 100 popqi
pop r14 ; ; 101 popqi
pop r13 ; ; 102 popqi
pop r12 ; ; 103 popqi
pop r11 ; ; 104 popqi
pop r10 ; ; 105 popqi
pop r9 ; ; 106 popqi
pop r8 ; ; 107 popqi
ret ; 108 return_from_epilogue