What does the .n suffix on instructions such as mov.n, add.n and retw.n mean, and why does it matter on an IoT chip?
.n marks a "narrow" instruction, encoded in 16 bits instead of the standard 24. The two sizes mix freely, so common instructions take less flash.
Standard Xtensa instructions are 24 bits long, already 25% smaller than the 32-bit instructions of many RISC processors. The code density option, which the ESP32 has, adds 16-bit versions of the most frequent instructions: moves, adds, loads and stores with small offsets, returns. They do the same thing as their 24-bit counterparts but can only encode a subset of the operands, for example small constants.
Since the processor tells the two lengths apart by their opcode, the compiler can use the short form wherever it fits and the long form elsewhere, instruction by instruction.
On a desktop, a few kilobytes of code don't matter. On a microcontroller the firmware has to fit in a few megabytes of flash and run through a small instruction cache, so smaller code means more features fit and fewer cache misses.
Tip: .n = narrow = half a word shorter.
Go deeper:
GNU as — Xtensa-dependent features — how the assembler picks narrow forms and the
.nsuffix.