From: Wilhelm Meier <wilhelm.meier@hs-kl.de>
To: gcc-help <gcc-help@gcc.gnu.org>
Subject: avr-gcc: direct register access suppresses optimization
Date: Tue, 14 Feb 2023 10:32:03 +0100 [thread overview]
Message-ID: <2e0f499b-b854-bde4-ba73-e2e37c3cf334@hs-kl.de> (raw)
The follwing example contains functional identicaal code:
<1> uses direct register access
<2> uses structure mapping
But <1> suppresses the hoist/sink of the loads/stores to variable g out
of the loop. In case <2> this optimization is done (and is correct).
What does avr-gcc hinder to do this optimization in case <1>?
#include <avr/io.h>
#include <stdint.h>
static uint16_t g;
int main() {
for(uint8_t i = 0; i < 20; i++) {
++g;
// VPORTA_DIR; // <1> suppresses optimization
VPORTA.DIR; // <2>
}
}
reply other threads:[~2023-02-14 9:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=2e0f499b-b854-bde4-ba73-e2e37c3cf334@hs-kl.de \
--to=wilhelm.meier@hs-kl.de \
--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).