From: Gabriele Favalessa <gabriele@rzerosystems.com>
To: gcc-help@gcc.gnu.org
Subject: ARM: code size increase starting from gcc 10
Date: Fri, 11 Mar 2022 10:57:14 +0100 [thread overview]
Message-ID: <CAGRyuqx8Y=KsqGGOEG6OtdQo_U68Wx-=OHe6yJqMNDqiZ-dUXw@mail.gmail.com> (raw)
Hi,
up to gcc 9 this function
#include <stdint.h>
#include <stdbool.h>
bool f() {
return *(volatile uint32_t*)0x42143fa8 == 0;
}
compiles (arm-none-eabi-gcc -mcpu=cortex-m4 -Os) to:
0: 4b02 ldr r3, [pc, #8] ; (c <f+0xc>)
2: 6818 ldr r0, [r3, #0]
4: fab0 f080 clz r0, r0
8: 0940 lsrs r0, r0, #5
a: 4770 bx lr
c: 42143fa8 .word 0x42143fa8
Starting with gcc 10 it compiles to:
0: 4b03 ldr r3, [pc, #12] ; (10 <f+0x10>)
2: f8d3 0fa8 ldr.w r0, [r3, #4008] ; 0xfa8
6: fab0 f080 clz r0, r0
a: 0940 lsrs r0, r0, #5
c: 4770 bx lr
e: bf00 nop
10: 42143000 .word 0x42143000
Questions:
1) why newer gcc versions don't generate the smallest possible size in
spite of -Os?
2) is there a way to get the smaller code with newer gcc versions?
Thanks
Gabriele
next reply other threads:[~2022-03-11 9:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 9:57 Gabriele Favalessa [this message]
2022-03-11 15:20 ` Richard Earnshaw
2022-03-14 10:05 ` Gabriele Favalessa
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='CAGRyuqx8Y=KsqGGOEG6OtdQo_U68Wx-=OHe6yJqMNDqiZ-dUXw@mail.gmail.com' \
--to=gabriele@rzerosystems.com \
--cc=gcc-help@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).