https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108778
--- Comment #2 from Wilhelm M <klaus.doldinger64 at googlemail dot com> --- Or even simpler: #include <avr/io.h> #include <stdint.h> static uint16_t g; int main() { for(uint8_t i = 0; i < 20; i++) { ++g; // VPORTA_DIR; // suppresses optimization VPORTA.DIR; } }