3 ms·
I think "micro optimizations" would be a good category to put them in (although in my experience the term is usually used in a negative way). > The C compiler
by atiedebee 2y ago
I think "micro optimizations" would be a good category to put them in (although in my experience the term is usually used in a negative way).
> The C compiler might unroll a loop for you, for example. But often it won't
I've found that clang unrolls loops really aggressively compared to GCC on O2, to the point that I think that the majority of loops is getting unrolled
- kragen 2y agoIn that case, on a computer with an instruction cache, you can probably optimize your program by not unrolling the loops that aren't hot. Maybe you can compile those parts of the program with GCC. Micro-optimizations are in many cases not justifiable, for the reasons Knuth explains in his paper. But sometimes they are.