public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/11181] New: [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code.
@ 2003-06-13 3:10 dmixm@marine.febras.ru
2003-07-06 1:30 ` [Bug optimization/11181] " pinskia at physics dot uc dot edu
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: dmixm@marine.febras.ru @ 2003-06-13 3:10 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11181
Summary: [avr-gcc] Optimization of "uchar/xor/and/single_bit"
produced wrong code.
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: dmixm@marine.febras.ru
CC: gcc-bugs@gcc.gnu.org
GCC target triplet: avr-unknown-none
Optimization of next program produced infinite loop:
unsigned char f(void);
void foo(void)
{
while ( ((f() ^ 1) & 1) == 0 ) ;
}
Result is (avr-gcc -W -Wall -O1 -S xor.c):
.file "xor.c"
.arch avr2
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
.global __do_copy_data
.global __do_clear_bss
.text
.global foo
.type foo, @function
foo:
/* prologue: frame size=0 */
push r28
/* prologue end (size=1) */
.L2:
rcall f
rjmp .L2
/* epilogue: frame size=0 */
/* epilogue: noreturn */
/* epilogue end (size=0) */
/* function foo size 3 (2) */
.size foo, .-foo
/* File "xor.c": code 3 = 0x0003 ( 2), prologues 1, epilogues 0 */
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug optimization/11181] [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code.
2003-06-13 3:10 [Bug optimization/11181] New: [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code dmixm@marine.febras.ru
@ 2003-07-06 1:30 ` pinskia at physics dot uc dot edu
2003-07-06 1:59 ` pinskia at physics dot uc dot edu
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-06 1:30 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11181
pinskia at physics dot uc dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2003-07-06 01:30:31
date| |
------- Additional Comments From pinskia at physics dot uc dot edu 2003-07-06 01:30 -------
I can confirm this on the mainline (20030706) but with -Os.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug optimization/11181] [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code.
2003-06-13 3:10 [Bug optimization/11181] New: [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code dmixm@marine.febras.ru
2003-07-06 1:30 ` [Bug optimization/11181] " pinskia at physics dot uc dot edu
@ 2003-07-06 1:59 ` pinskia at physics dot uc dot edu
2003-07-28 12:23 ` ehrhardt at mathematik dot uni-ulm dot de
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-06 1:59 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11181
pinskia at physics dot uc dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Target Milestone|3.4 |---
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug optimization/11181] [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code.
2003-06-13 3:10 [Bug optimization/11181] New: [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code dmixm@marine.febras.ru
2003-07-06 1:30 ` [Bug optimization/11181] " pinskia at physics dot uc dot edu
2003-07-06 1:59 ` pinskia at physics dot uc dot edu
@ 2003-07-28 12:23 ` ehrhardt at mathematik dot uni-ulm dot de
2003-07-28 16:20 ` pinskia at physics dot uc dot edu
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: ehrhardt at mathematik dot uni-ulm dot de @ 2003-07-28 12:23 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11181
ehrhardt at mathematik dot uni-ulm dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |WAITING
Target Milestone|--- |3.3.2
------- Additional Comments From ehrhardt at mathematik dot uni-ulm dot de 2003-07-28 12:23 -------
This appears to be a duplicate of 11662. Could you try the patch
attached to that report and see if that help?
regards Christian
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug optimization/11181] [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code.
2003-06-13 3:10 [Bug optimization/11181] New: [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code dmixm@marine.febras.ru
` (2 preceding siblings ...)
2003-07-28 12:23 ` ehrhardt at mathematik dot uni-ulm dot de
@ 2003-07-28 16:20 ` pinskia at physics dot uc dot edu
2003-07-28 16:27 ` [Bug optimization/11181] [3.3 only][avr-gcc] " pinskia at physics dot uc dot edu
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-28 16:20 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11181
------- Additional Comments From pinskia at physics dot uc dot edu 2003-07-28 16:20 -------
It looks like the mainline (20030728) is still broken with -Os (but I do not read avr asm.):
.L2:
rcall f
ldi r25,lo8(1)
eor r25,r24
sbrs r25,0
rjmp .L2
Could you say if that works (is rjmp unconditional jump?)?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug optimization/11181] [3.3 only][avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code.
2003-06-13 3:10 [Bug optimization/11181] New: [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code dmixm@marine.febras.ru
` (3 preceding siblings ...)
2003-07-28 16:20 ` pinskia at physics dot uc dot edu
@ 2003-07-28 16:27 ` pinskia at physics dot uc dot edu
2003-07-28 16:42 ` ehrhardt at mathematik dot uni-ulm dot de
2003-08-03 16:19 ` pinskia at physics dot uc dot edu
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-28 16:27 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11181
pinskia at physics dot uc dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[avr-gcc] Optimization of |[3.3 only][avr-gcc]
|"uchar/xor/and/single_bit" |Optimization of
|produced wrong code. |"uchar/xor/and/single_bit"
| |produced wrong code.
------- Additional Comments From pinskia at physics dot uc dot edu 2003-07-28 16:27 -------
It works on the mainline, I looked at the RTL at the last stage and it had:
(jump_insn 19 18 24 (set (pc)
(if_then_else (eq (zero_extract:HI (reg:QI 25 r25 [42])
(const_int 1 [0x1])
(const_int 0 [0x0]))
(const_int 0 [0x0]))
(label_ref 9)
(pc))) 97 {*sbrx_branch} (insn_list 13 (nil))
(expr_list:REG_DEAD (reg:QI 25 r25 [42])
(expr_list:REG_BR_PROB (const_int 8900 [0x22c4])
(nil))))
So it worked.
I will test the patch to find out if it fixes the problem on 3.3.1.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug optimization/11181] [3.3 only][avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code.
2003-06-13 3:10 [Bug optimization/11181] New: [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code dmixm@marine.febras.ru
` (4 preceding siblings ...)
2003-07-28 16:27 ` [Bug optimization/11181] [3.3 only][avr-gcc] " pinskia at physics dot uc dot edu
@ 2003-07-28 16:42 ` ehrhardt at mathematik dot uni-ulm dot de
2003-08-03 16:19 ` pinskia at physics dot uc dot edu
6 siblings, 0 replies; 8+ messages in thread
From: ehrhardt at mathematik dot uni-ulm dot de @ 2003-07-28 16:42 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11181
------- Additional Comments From ehrhardt at mathematik dot uni-ulm dot de 2003-07-28 16:42 -------
Subject: Re: [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code.
On Mon, Jul 28, 2003 at 04:20:58PM -0000, pinskia at physics dot uc dot edu wrote:
> It looks like the mainline (20030728) is still broken with -Os
> (but I do not read avr asm.):
I've never seen an avr either ;-) But now gcc at least emmits an eor
after the call which is definitely a progression wrt. the assembly
in the audit trail.
> .L2:
> rcall f
> ldi r25,lo8(1)
> eor r25,r24
> sbrs r25,0
> rjmp .L2
I found an avr tutorial at
http://www.avr-asm-tutorial.net/avr_en/beginner/index.html
and this tells me that sbrs skips the next instruction if Bit 0 in r25
ist set. I.e. this code looks correct to me.
regards Christian
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug optimization/11181] [3.3 only][avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code.
2003-06-13 3:10 [Bug optimization/11181] New: [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code dmixm@marine.febras.ru
` (5 preceding siblings ...)
2003-07-28 16:42 ` ehrhardt at mathematik dot uni-ulm dot de
@ 2003-08-03 16:19 ` pinskia at physics dot uc dot edu
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-03 16:19 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11181
pinskia at physics dot uc dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution| |DUPLICATE
------- Additional Comments From pinskia at physics dot uc dot edu 2003-08-03 16:19 -------
Since the patch for PR 11662 fixes this bug, I am closing as a dup of bug 11662.
*** This bug has been marked as a duplicate of 11662 ***
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-08-03 16:19 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-13 3:10 [Bug optimization/11181] New: [avr-gcc] Optimization of "uchar/xor/and/single_bit" produced wrong code dmixm@marine.febras.ru
2003-07-06 1:30 ` [Bug optimization/11181] " pinskia at physics dot uc dot edu
2003-07-06 1:59 ` pinskia at physics dot uc dot edu
2003-07-28 12:23 ` ehrhardt at mathematik dot uni-ulm dot de
2003-07-28 16:20 ` pinskia at physics dot uc dot edu
2003-07-28 16:27 ` [Bug optimization/11181] [3.3 only][avr-gcc] " pinskia at physics dot uc dot edu
2003-07-28 16:42 ` ehrhardt at mathematik dot uni-ulm dot de
2003-08-03 16:19 ` pinskia at physics dot uc dot edu
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).