From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18024 invoked by alias); 20 Dec 2012 15:24:05 -0000 Received: (qmail 17579 invoked by uid 48); 20 Dec 2012 15:23:26 -0000 From: "freddie_chopin at op dot pl" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: freddie_chopin at op dot pl X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg01988.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55757 --- Comment #1 from Freddie Chopin 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 : 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 : 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