Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In hot code, base will be cached in a register.


I don’t think so.

It can be cached by very small chance. Or it can be cached if the developer did profile-guided optimization. Otherwise it’ll be evicted from these registers pretty often. There’re not that many general purpose registers, so unless the processing code is trivially simple like CRC32, the compiler will reuse these registers for something else.


I wrote a lot of the Rust compiler. Slice base and length is almost always cached if it matters for performance.


OK, but wasting 2 general purpose registers on that, out of just 15 available, also matters for performance.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: