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

>Bonus authenticity: use `a^=a` to zero a register in a single x86 instruction (and makes a real difference for compiler toolchains 30+ years old).

Modern compilers will still use xor for zeroing registers on their own.

For instance: https://godbolt.org/z/n5n35xjqx

Variable a(register esi) is first initialized to 42 with mov and then cleared to zero using xor.



Yes, the whole comment is tongue in cheek for pointless manual optimizations.




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

Search: