"Bill McEnaney" <bill@xxxxxxxxxxxx> writes: > Various people disagree about whether I should multiply by a reciprocal > when I could do a floating point division instead. Others tell me that > it's best to let the compiler replace integer division by a power of two > with a right shift. If I do either optimization by hand, will that > prevent the compiler from noticing other optimizations it could do? > I've read somewhere that I should let C compilers do the optimizations > I've described. Is that true about gcc's C compiler? Is it bet for me > to trust it to do optimizations I could do? Unless your code is performance critical, you should write whatever code will be easier for people to read and understand. In the relatively rare case that the code is performance critical, then you should certainly do whatever generates the faster assembly code, and revisit the issue whenever you run the program on a new computer. gcc is able to both optimizations you mention, and it will do them, when optimizing, when it is beneficial. Ian