public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/39386] New: different computation results for O1 and O0 executables
@ 2009-03-05 21:17 jxyang at cs dot utah dot edu
2009-03-05 21:22 ` [Bug target/39386] " jxyang at cs dot utah dot edu
` (9 more replies)
0 siblings, 10 replies; 17+ messages in thread
From: jxyang at cs dot utah dot edu @ 2009-03-05 21:17 UTC (permalink / raw)
To: gcc-bugs
This is seen on the version of avr-gcc 4.3.3 that gets built by the script that
comes with FemtoOS 0.88.
The program performs simple arithmatic and logical operations on a global
variable, and store the result in register R30:R31.
If the program is compiled with "avr-gcc -mmcu=atmega128 -O0", the final result
is 00. On the other hand, if the program is compiled with "avr-gcc
-mmcu=atmega128 -O1", the final result is 0xFF. Compiling at O2 gives me 0xFF
too.
Obviously, avr-gcc compiled the program wrong at one of the these optimization
levels.
This bug is observed in avr studio 4.15.
--
Summary: different computation results for O1 and O0 executables
Product: gcc
Version: 4.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jxyang at cs dot utah dot edu
GCC build triplet: --target=avr --with-gnu-ld --with-gnu-as --enable-
languages=c,c+
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: avr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] different computation results for O1 and O0 executables
2009-03-05 21:17 [Bug target/39386] New: different computation results for O1 and O0 executables jxyang at cs dot utah dot edu
@ 2009-03-05 21:22 ` jxyang at cs dot utah dot edu
2009-03-18 17:47 ` [Bug target/39386] [avr] " eric dot weddington at atmel dot com
` (8 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: jxyang at cs dot utah dot edu @ 2009-03-05 21:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from jxyang at cs dot utah dot edu 2009-03-05 21:22 -------
Created an attachment (id=17400)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17400&action=view)
mis-calculated program
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
2009-03-05 21:17 [Bug target/39386] New: different computation results for O1 and O0 executables jxyang at cs dot utah dot edu
2009-03-05 21:22 ` [Bug target/39386] " jxyang at cs dot utah dot edu
@ 2009-03-18 17:47 ` eric dot weddington at atmel dot com
2009-03-21 16:53 ` eric dot weddington at atmel dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: eric dot weddington at atmel dot com @ 2009-03-18 17:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from eric dot weddington at atmel dot com 2009-03-18 17:47 -------
Confirmed with gcc 4.3.2.
--
eric dot weddington at atmel dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Known to fail| |4.3.3 4.3.2
Last reconfirmed|0000-00-00 00:00:00 |2009-03-18 17:47:31
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
2009-03-05 21:17 [Bug target/39386] New: different computation results for O1 and O0 executables jxyang at cs dot utah dot edu
2009-03-05 21:22 ` [Bug target/39386] " jxyang at cs dot utah dot edu
2009-03-18 17:47 ` [Bug target/39386] [avr] " eric dot weddington at atmel dot com
@ 2009-03-21 16:53 ` eric dot weddington at atmel dot com
2009-04-07 15:18 ` eric dot weddington at atmel dot com
` (6 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: eric dot weddington at atmel dot com @ 2009-03-21 16:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from eric dot weddington at atmel dot com 2009-03-21 16:52 -------
Please try using gcc 4.4 (HEAD). Anatoly Sokolov (AVR port maintainer) has
indicated to me that he does not see this bug when using HEAD/4.4.
--
eric dot weddington at atmel dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
2009-03-05 21:17 [Bug target/39386] New: different computation results for O1 and O0 executables jxyang at cs dot utah dot edu
` (2 preceding siblings ...)
2009-03-21 16:53 ` eric dot weddington at atmel dot com
@ 2009-04-07 15:18 ` eric dot weddington at atmel dot com
2009-04-07 15:23 ` eric dot weddington at atmel dot com
` (5 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: eric dot weddington at atmel dot com @ 2009-04-07 15:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from eric dot weddington at atmel dot com 2009-04-07 15:18 -------
*** Bug 39635 has been marked as a duplicate of this bug. ***
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
2009-03-05 21:17 [Bug target/39386] New: different computation results for O1 and O0 executables jxyang at cs dot utah dot edu
` (3 preceding siblings ...)
2009-04-07 15:18 ` eric dot weddington at atmel dot com
@ 2009-04-07 15:23 ` eric dot weddington at atmel dot com
2009-08-10 13:27 ` anitha dot boyapati at atmel dot com
` (4 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: eric dot weddington at atmel dot com @ 2009-04-07 15:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from eric dot weddington at atmel dot com 2009-04-07 15:23 -------
Adding additional version numbers in the known-to-fail field from comment in
duplicate bug #39635. Still waiting to hear if bug is present in 4.4.
--
eric dot weddington at atmel dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wvangulik at xs4all dot nl
GCC host triplet|i686-pc-linux-gnu |
Keywords| |wrong-code
Known to fail|4.3.3 4.3.2 |4.3.3 4.3.2 4.1.2 4.2.2
| |4.3.0 4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
2009-03-05 21:17 [Bug target/39386] New: different computation results for O1 and O0 executables jxyang at cs dot utah dot edu
` (4 preceding siblings ...)
2009-04-07 15:23 ` eric dot weddington at atmel dot com
@ 2009-08-10 13:27 ` anitha dot boyapati at atmel dot com
2009-08-10 13:41 ` eric dot weddington at atmel dot com
` (3 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: anitha dot boyapati at atmel dot com @ 2009-08-10 13:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from anitha dot boyapati at atmel dot com 2009-08-10 13:27 -------
Confirmed with gcc 4.4.0. Using switch -O0 with avr-gcc 4.4.0 (-mmcu=atmega128)
gave the result 0 while -O1 gave 0xFF
--
anitha dot boyapati at atmel dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anitha dot boyapati at atmel
| |dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
2009-03-05 21:17 [Bug target/39386] New: different computation results for O1 and O0 executables jxyang at cs dot utah dot edu
` (5 preceding siblings ...)
2009-08-10 13:27 ` anitha dot boyapati at atmel dot com
@ 2009-08-10 13:41 ` eric dot weddington at atmel dot com
2010-08-23 13:09 ` anitha dot boyapati at atmel dot com
` (2 subsequent siblings)
9 siblings, 0 replies; 17+ messages in thread
From: eric dot weddington at atmel dot com @ 2009-08-10 13:41 UTC (permalink / raw)
To: gcc-bugs
--
eric dot weddington at atmel dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |NEW
Last reconfirmed|2009-03-18 17:47:31 |2009-08-10 13:40:54
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
2009-03-05 21:17 [Bug target/39386] New: different computation results for O1 and O0 executables jxyang at cs dot utah dot edu
` (6 preceding siblings ...)
2009-08-10 13:41 ` eric dot weddington at atmel dot com
@ 2010-08-23 13:09 ` anitha dot boyapati at atmel dot com
2010-08-23 13:25 ` anitha dot boyapati at atmel dot com
2010-08-23 13:36 ` wvangulik at xs4all dot nl
9 siblings, 0 replies; 17+ messages in thread
From: anitha dot boyapati at atmel dot com @ 2010-08-23 13:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from anitha dot boyapati at atmel dot com 2010-08-23 13:08 -------
Created an attachment (id=21547)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21547&action=view)
Reduced testcase
Reduced testcase to reproduce the bug.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
2009-03-05 21:17 [Bug target/39386] New: different computation results for O1 and O0 executables jxyang at cs dot utah dot edu
` (7 preceding siblings ...)
2010-08-23 13:09 ` anitha dot boyapati at atmel dot com
@ 2010-08-23 13:25 ` anitha dot boyapati at atmel dot com
2010-08-23 13:36 ` wvangulik at xs4all dot nl
9 siblings, 0 replies; 17+ messages in thread
From: anitha dot boyapati at atmel dot com @ 2010-08-23 13:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from anitha dot boyapati at atmel dot com 2010-08-23 13:25 -------
When -O2 is enabled result is 0xFF (255) which is incorrect. The code generated
for the following shift operation:
13: return (left << right);
+000000AB: C004 RJMP PC+0x0005 Relative jump
+000000AC: 0F22 LSL R18 Logical Shift Left
+000000AD: 1F33 ROL R19 Rotate Left Through Carry
+000000AE: 1F44 ROL R20 Rotate Left Through Carry
+000000AF: 1F55 ROL R21 Rotate Left Through Carry
+000000B0: 952A DEC R18 Decrement
+000000B1: F7D2 BRPL PC-0x05 Branch if plus
19: g_6= func_1 (g_6, g_6);
+000000B2: 93200100 STS 0x0100,R18 Store direct to data space
'left' is stored in registers R21:R20:R19:R18 as it is typecasted to uint32_t
type while 'right' is stored in R18. Because of shift logic, R18 becomes 0xFF
in first iteration which is then stored.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
2009-03-05 21:17 [Bug target/39386] New: different computation results for O1 and O0 executables jxyang at cs dot utah dot edu
` (8 preceding siblings ...)
2010-08-23 13:25 ` anitha dot boyapati at atmel dot com
@ 2010-08-23 13:36 ` wvangulik at xs4all dot nl
9 siblings, 0 replies; 17+ messages in thread
From: wvangulik at xs4all dot nl @ 2010-08-23 13:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from wvangulik at xs4all dot nl 2010-08-23 13:36 -------
I already generated a simple testcase (although different)in
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39635. The comments from Andy in
the linked report might be worth reproducing here
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
[not found] <bug-39386-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2011-07-25 15:47 ` gjl at gcc dot gnu.org
@ 2011-07-25 16:09 ` gjl at gcc dot gnu.org
5 siblings, 0 replies; 17+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-07-25 16:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
Georg-Johann Lay <gjl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #14 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-07-25 16:08:04 UTC ---
Closed as FIXED.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
[not found] <bug-39386-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2011-07-25 15:44 ` gjl at gcc dot gnu.org
@ 2011-07-25 15:47 ` gjl at gcc dot gnu.org
2011-07-25 16:09 ` gjl at gcc dot gnu.org
5 siblings, 0 replies; 17+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-07-25 15:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
--- Comment #13 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-07-25 15:45:51 UTC ---
Author: gjl
Date: Mon Jul 25 15:45:47 2011
New Revision: 176757
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176757
Log:
PR target/39386
Backport from mainline r176756
2011-07-25 Georg-Johann Lay
* config/avr/avr.c (out_shift_with_cnt): Use tmp_reg as
shift counter for x << x and x >> x shifts.
Modified:
branches/gcc-4_6-branch/gcc/ChangeLog
branches/gcc-4_6-branch/gcc/config/avr/avr.c
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
[not found] <bug-39386-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2011-07-23 13:48 ` gjl at gcc dot gnu.org
@ 2011-07-25 15:44 ` gjl at gcc dot gnu.org
2011-07-25 15:47 ` gjl at gcc dot gnu.org
2011-07-25 16:09 ` gjl at gcc dot gnu.org
5 siblings, 0 replies; 17+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-07-25 15:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
--- Comment #12 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-07-25 15:42:00 UTC ---
Author: gjl
Date: Mon Jul 25 15:41:55 2011
New Revision: 176756
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176756
Log:
PR target/39386
* config/avr/avr.c (out_shift_with_cnt): Use tmp_reg as
shift counter for x << x and x >> x shifts.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/avr/avr.c
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
[not found] <bug-39386-4@http.gcc.gnu.org/bugzilla/>
2011-07-23 10:09 ` gjl at gcc dot gnu.org
2011-07-23 10:23 ` gjl at gcc dot gnu.org
@ 2011-07-23 13:48 ` gjl at gcc dot gnu.org
2011-07-25 15:44 ` gjl at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-07-23 13:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
--- Comment #11 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-07-23 13:48:14 UTC ---
Created attachment 24814
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24814
Minimal testcase
Minimal testcase that also miscompiles for newer versions of the compiler like
4.5.2 or 4.6.1.
Compiles with -Os to
shift:
rjmp 2f
1: lsl r24
rol r25
2: dec r24
brpl 1b
ret
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
[not found] <bug-39386-4@http.gcc.gnu.org/bugzilla/>
2011-07-23 10:09 ` gjl at gcc dot gnu.org
@ 2011-07-23 10:23 ` gjl at gcc dot gnu.org
2011-07-23 13:48 ` gjl at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-07-23 10:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
Georg-Johann Lay <gjl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.6.2
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug target/39386] [avr] different computation results for O1 and O0 executables
[not found] <bug-39386-4@http.gcc.gnu.org/bugzilla/>
@ 2011-07-23 10:09 ` gjl at gcc dot gnu.org
2011-07-23 10:23 ` gjl at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: gjl at gcc dot gnu.org @ 2011-07-23 10:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39386
Georg-Johann Lay <gjl at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gjl at gcc dot gnu.org
Known to fail| |
--- Comment #10 from Georg-Johann Lay <gjl at gcc dot gnu.org> 2011-07-23 10:08:33 UTC ---
The problem arises from the following insns:
*ashlqi3
ashlhi3
ashlsi3
ashrqi3
ashrhi3
ashrsi3
*lshrqi3
lshrhi3
lshrsi3
For variable shifts the first constraint alternative is "=r,0,r"
avr.c:out_shift_with_cnt() reads
else if (register_operand (operands[2], QImode))
{
if (reg_unused_after (insn, operands[2]))
op[3] = op[2];
else
{
op[3] = tmp_reg_rtx;
if (!len)
strcat (str, (AS2 (mov,%3,%2) CR_TAB));
}
}
so that in the very rare, pathological case of op0 = op1 = op2 and op2 is
unused after the insn, wrong code gets generated. Fix is:
if (reg_unused_after (insn, operands[2])
&& !reg_overlap_mentioned_p (operands[0], operands[2]))
or something like that.
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2011-07-25 16:09 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-05 21:17 [Bug target/39386] New: different computation results for O1 and O0 executables jxyang at cs dot utah dot edu
2009-03-05 21:22 ` [Bug target/39386] " jxyang at cs dot utah dot edu
2009-03-18 17:47 ` [Bug target/39386] [avr] " eric dot weddington at atmel dot com
2009-03-21 16:53 ` eric dot weddington at atmel dot com
2009-04-07 15:18 ` eric dot weddington at atmel dot com
2009-04-07 15:23 ` eric dot weddington at atmel dot com
2009-08-10 13:27 ` anitha dot boyapati at atmel dot com
2009-08-10 13:41 ` eric dot weddington at atmel dot com
2010-08-23 13:09 ` anitha dot boyapati at atmel dot com
2010-08-23 13:25 ` anitha dot boyapati at atmel dot com
2010-08-23 13:36 ` wvangulik at xs4all dot nl
[not found] <bug-39386-4@http.gcc.gnu.org/bugzilla/>
2011-07-23 10:09 ` gjl at gcc dot gnu.org
2011-07-23 10:23 ` gjl at gcc dot gnu.org
2011-07-23 13:48 ` gjl at gcc dot gnu.org
2011-07-25 15:44 ` gjl at gcc dot gnu.org
2011-07-25 15:47 ` gjl at gcc dot gnu.org
2011-07-25 16:09 ` gjl at gcc dot gnu.org
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).