title: Visual Studio C++ compiler options: Why does /O2 define /Gs?
body: <p>The Visual Studio C++ compiler option <a href="http://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx" rel="noreferrer">/O2</a> (maximize speed) is equivalent to</p>
  
  <pre><code>/Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy
  </code></pre>
  
  <p>Why <a href="http://msdn.microsoft.com/en-us/library/9598wk25%28v=vs.100%29.aspx" rel="noreferrer">/Gs</a>? How does it help maximize speed? (Note that it is <a href="http://msdn.microsoft.com/en-us/library/9598wk25%28v=vs.100%29.aspx" rel="noreferrer">/Gs</a>, not <a href="http://msdn.microsoft.com/en-us/library/8dbf701c.aspx" rel="noreferrer">/GS</a>.)</p>