public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gpib at rickyrockrat dot net" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/52301] New: avr-gcc 4.6.2 produces NOP loop in simple while statement Date: Fri, 17 Feb 2012 21:30:00 -0000 [thread overview] Message-ID: <bug-52301-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52301 Bug #: 52301 Summary: avr-gcc 4.6.2 produces NOP loop in simple while statement Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: major Priority: P3 Component: c AssignedTo: unassigned@gcc.gnu.org ReportedBy: gpib@rickyrockrat.net Created attachment 26696 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26696 Problem source code The while loop produces a jump to L3 which is = L5. The code immediately following jumps to L5, which does nothing but loop. In a main function, I have a loop like so: while(1) { if (stat &DAT_READY) { cli(); stat=0; sei(); } Which produces this asm code: 89 .L6: 64:spi_irq_echo.c **** sei(); // Enable global interrupts 90 .loc 1 64 0 91 /* #APP */ 92 ; 64 "spi_irq_echo.c" 1 93 0016 7894 sei 94 ; 0 "" 2 65:spi_irq_echo.c **** while(1) { 66:spi_irq_echo.c **** if (stat &DAT_READY) { 95 .loc 1 66 0 96 /* #NOAPP */ 97 0018 8091 0000 lds r24,stat 98 001c 80FF sbrs r24,0 99 001e 00C0 rjmp .L3 67:spi_irq_echo.c **** cli(); 100 .loc 1 67 0 101 /* #APP */ 102 ; 67 "spi_irq_echo.c" 1 103 0020 F894 cli 104 ; 0 "" 2 \fGAS LISTING /tmp/ccXonaYI.s page 4 68:spi_irq_echo.c **** stat=0; 105 .loc 1 68 0 106 /* #NOAPP */ 107 0022 1092 0000 sts stat,__zero_reg__ 108 0026 00C0 rjmp .L6 109 .L3: 110 .L5: 111 0028 00C0 rjmp .L5 112 .cfi_endproc If add a global that is u8 x, and modify the loop as follows: while(1) { x=1; if (stat &DAT_READY) { cli(); stat=0; sei(); } It produces the correct assembler. Command line is: avr-gcc -Os -Wa,-a=spi_irq_echo.x -fno-zero-initialized-in-bss -Wall -g -mmcu=attiny26 -mshort-calls -mtiny-stack -I ../../common -I. -c -o spi_irq_echo.o spi_irq_echo.c Complete file is attached.
next reply other threads:[~2012-02-17 21:28 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-02-17 21:30 gpib at rickyrockrat dot net [this message] 2012-02-21 3:45 ` [Bug target/52301] " pinskia at gcc dot gnu.org 2012-02-22 4:29 ` gpib at rickyrockrat dot net 2012-02-22 4:31 ` gpib at rickyrockrat dot net 2012-02-22 4:34 ` gpib at rickyrockrat dot net 2012-02-22 4:42 ` pinskia at gcc dot gnu.org 2012-02-22 5:32 ` gpib at rickyrockrat dot net
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-52301-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).