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.
What this page will cover
Section titled “What this page will cover”- Types: signedness, widths, pointers versus arrays, struct copies.
- Control flow: loops, early returns,
switchand 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:
staticversus global,constplacement, 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.