Skip to content

Common patterns

After a while you start recognizing diffs: “that’s a signed load where I wrote unsigned”, “that branch means the loop was written the other way round”. This page will collect those patterns, grouped by what the diff looks like, with small before-and-after examples.

  • Types: signedness, widths, pointers versus arrays, struct copies.
  • Control flow: loops, early returns, switch and jump tables, conditions with side effects.
  • Expressions: evaluation order, temporaries, casts, constant folding.
  • Register allocation: what tends to move registers, and what doesn’t.
  • Data: static versus global, const placement, string pooling, alignment.
  • Per compiler: shapes that only matter for one compiler family. See Compilers.

Each pattern will say which compilers it was verified with.