public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* avr-gcc: direct register access suppresses optimization
@ 2023-02-14  9:32 Wilhelm Meier
  0 siblings, 0 replies; only message in thread
From: Wilhelm Meier @ 2023-02-14  9:32 UTC (permalink / raw)
  To: gcc-help

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>
     }
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-14  9:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14  9:32 avr-gcc: direct register access suppresses optimization Wilhelm Meier

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).