public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "gjl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/49807] New: Missed byte (subreg) extraction Date: Thu, 21 Jul 2011 19:32:00 -0000 [thread overview] Message-ID: <bug-49807-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49807 Summary: Missed byte (subreg) extraction Product: gcc Version: 4.6.1 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: gjl@gcc.gnu.org Target: avr This C source: #define SPDR (*((char volatile*) 0x2c)) void read_adc (long big) { SPDR = big >> 24; SPDR = big >> 16; SPDR = big >> 8; SPDR = big; } compiles with avr-gcc -S -Os -dp -mmcu=atmega8 to: read_adc: movw r26,r24 ; 2 *movsi/1 [length = 2] movw r24,r22 mov r20,r27 ; 28 *ashrsi3_const/3 [length = 6] clr r23 sbrc r20,7 com r23 mov r21,r23 mov r22,r23 out 44-0x20,r20 ; 9 *movqi/3 [length = 1] movw r20,r26 ; 29 *ashrsi3_const/3 [length = 5] clr r23 sbrc r21,7 com r23 mov r22,r23 out 44-0x20,r20 ; 13 *movqi/3 [length = 1] mov r20,r25 ; 30 *ashrsi3_const/3 [length = 6] mov r21,r26 mov r22,r27 clr r23 sbrc r22,7 dec r23 out 44-0x20,r20 ; 17 *movqi/3 [length = 1] out 44-0x20,r24 ; 20 *movqi/3 [length = 1] ret ; 26 return [length = 1] The shifts are done explicitely where the bytes could be saved directly. Combiner tries insns like Failed to match this instruction: (set (mem/v:QI (const_int 44)) (subreg:QI (reg:SI 49) 1)) But they don't match because of MEM_VOLATILE_P so that the MEM does not match memory_operand as obviously volatile_ok is 0 at that moment. Must the backend split such insns by hand? Changing the source like #define SPDR0 (*((char*) 0x2c)) #define SPDR1 (*((char*) 0x2d)) #define SPDR2 (*((char*) 0x2e)) #define SPDR3 (*((char*) 0x2f)) void read_adc (long big) { SPDR0 = big >> 24; SPDR1 = big >> 16; SPDR2 = big >> 8; SPDR3 = big; } and it compiles fine: read_adc: out 44-0x20,r25 ; 8 *movqi/3 [length = 1] out 45-0x20,r24 ; 11 *movqi/3 [length = 1] out 46-0x20,r23 ; 14 *movqi/3 [length = 1] out 47-0x20,r22 ; 16 *movqi/3 [length = 1] ret ; 26 return [length = 1] == configure == Target: avr Configured with: ../../gcc.gnu.org/gcc-4_6-branch/configure --target=avr --prefix=/local/gnu/install/gcc-4.6-mingw32 --host=i586-mingw32 --build=i686-linux-gnu --enable-languages=c,c++ --disable-nls --disable-shared --with-dwarf2 Thread model: single gcc version 4.6.1 20110620 (prerelease) (GCC)
next reply other threads:[~2011-07-21 19:32 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-07-21 19:32 gjl at gcc dot gnu.org [this message] 2011-07-21 19:34 ` [Bug rtl-optimization/49807] " gjl at gcc dot gnu.org 2011-07-21 19:35 ` gjl at gcc dot gnu.org 2011-07-21 20:14 ` [Bug rtl-optimization/49807] Missed byte (subreg) extraction when storing to volatile mem eric.weddington at atmel dot com 2011-07-21 20:34 ` gjl at gcc dot gnu.org 2011-07-21 20:39 ` Andrew Pinski 2011-07-21 20:39 ` pinskia at gmail dot com 2011-07-21 20:46 ` gjl at gcc dot gnu.org 2011-07-23 22:16 ` pinskia at gcc dot gnu.org 2011-07-24 21:49 ` pinskia at gcc dot gnu.org
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-49807-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).