3 ms·
This misses the fact that signed integer promotions are generally not free because they require sign extension. For example, the cast in b() emits a `movsx` (mo
by colesbury 3y ago
This misses the fact that signed integer promotions are generally not free because they require sign extension. For example, the cast in b() emits a `movsx` (move with sign-extension). `movsx` is not free in the ways that `mov` can be.
`mov` can be "free" in two ways:
- the compiler can frequently avoid emitting the `mov` when part of a larger operation
- modern CPUs handle `mov` instructions earlier in the pipeline
Neither of those are true for `movsx`.