Re: minimise code size
This is a wide field.
The best approach is to realize a given function(ality) with as little code as possible - a discipline of its own.
Beyond that there are some commonalities between mcu architectures (decrementing an testing for zero is e.g. more efficient than incrementing and testing for some limit), but often the tradeoff is code size vs. speed (vs. RAM "consumption").
And you need to know your compiler as well - plus some more detail common to most (if not all) compilers.
Did you know there are 2 "flavors" of switch-case code generation available? A very fast one with constant execution time (occupying slightly more Flash space for a single-digit number of cases, beyond that being fast AND small) and the "usual one" that's getting slower "by the case(s)". But such knowledge comes only with experience and curiosity.
As I pride myself in writing extremely fast and small embedded software (e.g. an automotive HVAC controller in1400 bytes (including data)), I might know well what I'm doing.
PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)