You are probably aware of the material below, as it has a long history, but it is posted here for the amusement and possible education of others.
Zeroth Law of Optimization: First get it right, then get it fast.
You can do anything arbitrarily quickly as long as your code is not required to get the right answer.
First Law: Intelligence trumps code.
Use a good algorithm. Optimizing a bad algorithm is akin to polishing turds.
Second Law: Know what is going on.
Unless you profile your code and take timing measurements most everywhere, you don’t have a clue what is worth optimizing.
Third Law: Don’t do it.
Only calculate stuff you actually need. You might be surprised at how much extraneous garbage is computed in libraries, etc, without your knowledge.
Fourth Law: Don’t do it now.
Covers a number of issues, including lifting computations outside loops and storing stuff in registers or cache-friendly memory.