4 ms·
Compilers have improved a lot, to the point where you don't need to read this book for many of the tricks. For example, if you divide by a constant in gcc, you
by fefe23 4y ago
Compilers have improved a lot, to the point where you don't need to read this book for many of the tricks. For example, if you divide by a constant in gcc, you can see the tricks from this book being applied if you look at the disassembly.
Still, this is a standard textbook for little tricks. Knowing these kind of tricks used to be enough to make you a hacker in the original sense. I greatly enjoyed reading it and still recommend it even today.
It really is a delight for hackers.
- anonymoushn 4y agoIn gcc 9.3, it seems like it stops applying this optimization after maybe 30 constants. Pretty weird.
- beeforpork 4y agoThis is not only about optimisation, but often it provides you the idiom for coding something. E.g.: 'is x a power of two'? How to write this in a programming language? However unoptimised: how to actually code this test? HD tells you the idiom: (x & (x-1)) == 0, for any x != 0.