title: May compiler optimizations be inhibited by multi-threading?
body: <p>It happened to me a few times to parallelize portion of programs with OpenMP just to notice that in the end, despite the good scalability, most of the foreseen speed-up was lost due to the poor performance of the single threaded case (if compared to the serial version).</p>
  
  <p>The usual explanation that appears on the web for this behavior is that <em>the code generated by compilers may be worse in the multi-threaded case</em>. Anyhow I am not able to find anywhere a reference that explains <em>why</em> the assembly may be worse.</p>
  
  <p>So, what I would like to ask to the compiler guys out there is: </p>
  
  <p><strong>May compiler optimizations be inhibited by multi-threading? In case, how could performance be affected?</strong></p>
  
  <p>If it could help narrowing down the question I am mainly interested in high-performance computing.</p>
  
  <p><strong>Disclaimer</strong>: As stated in the comments, part of the answers below may become obsolete in the future as they briefly discuss the way in which optimizations are handled by compilers at the time the question was posed.</p>