public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "freddie_chopin at op dot pl" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/55757] Suboptimal interrupt prologue/epilogue for ARMv7-M (Cortex-M3)
Date: Thu, 20 Dec 2012 15:24:00 -0000	[thread overview]
Message-ID: <bug-55757-4-F6a1aPKPTz@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55757-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55757

--- Comment #1 from Freddie Chopin <freddie_chopin at op dot pl> 2012-12-20 15:23:25 UTC ---
BTW - it seems that optimization settings don't make any difference here - the
code below was compiled with -Os, on all other levels (1,2,3) the assembly
looks like this:

00002e90 <DMA_IRQHandler>:
void DMA_IRQHandler(void) __attribute((interrupt));
void DMA_IRQHandler(void)
{
    2e90:    4668          mov    r0, sp
    2e92:    f020 0107     bic.w    r1, r0, #7
    2e96:    468d          mov    sp, r1
    2e98:    b401          push    {r0}
}
    2e9a:    bc01          pop    {r0}
    2e9c:    4685          mov    sp, r0
    2e9e:    4770          bx    lr


So it just saves r0 only, without saving lr. It's actually 2 bytes smaller than
the assembly done for size optimizations (;

Without optimization (-O0) I get:

0000473c <DMA_IRQHandler>:
void DMA_IRQHandler(void) __attribute((interrupt));
void DMA_IRQHandler(void)
{
    473c:    4668          mov    r0, sp
    473e:    f020 0107     bic.w    r1, r0, #7
    4742:    468d          mov    sp, r1
    4744:    b481          push    {r0, r7}
    4746:    af00          add    r7, sp, #0
}
    4748:    46bd          mov    sp, r7
    474a:    bc81          pop    {r0, r7}
    474c:    4685          mov    sp, r0
    474e:    4770          bx    lr

The commandline options used to compile:

arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb -O0 -ffunction-sections
-fdata-sections -Wall -Wstrict-prototypes -Wextra -std=gnu99 -g -ggdb3
-fverbose-asm -Wa,-ahlms=out/uart.lst   -MD -MP -MF out/uart.d <some include
dirs> <input file> <output file>


  reply	other threads:[~2012-12-20 15:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-20 15:04 [Bug rtl-optimization/55757] New: " freddie_chopin at op dot pl
2012-12-20 15:24 ` freddie_chopin at op dot pl [this message]
2012-12-20 16:52 ` [Bug rtl-optimization/55757] " rearnsha at gcc dot gnu.org
2012-12-20 17:08 ` freddie_chopin at op dot pl
2012-12-21  3:23 ` joey.ye at arm dot com
2012-12-21  3:32 ` joey.ye at arm dot com
2012-12-21  7:09 ` freddie_chopin at op dot pl
2013-03-02 15:23 ` web at brolinembedded dot se
2023-11-28 23:10 ` yann at poupet dot eu

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-55757-4-F6a1aPKPTz@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: link
Be 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).