Hi I often see the following line used to toggle an output pin
(assuming bit is the pin to toggle)
PORTB ^= (1<<bit);
or similar
reading the data-sheets this is actually achievable in hardware simply by writing a 1 to the necessary bit in the PIN register
PINB = (1<<bit);
which compiles to a single instruction.
Does the compiler make this optimization?