Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://gcc.godbolt.org/#%7B%22version%22:3,%22filterAsm%22%3a%7B%22labels%22%3atrue,%22directives%22%3atrue,%22commentOnly%22%3atrue,%22intel%22%3atrue,%22colouriseAsm%22%3atrue%7D,%22compilers%22%3a%5B%7B%22source%22%3a%22//%20Preprocessor%5Cn#include%20%3Ciostream%3E%5Cn#include%20%3Cvector%3E%5Cn%5Cn//%20Internal%20branching%5Cnvoid%20f1%28std%3a%3avector%3Cint%3E&amp;%20v,%5Cn%20%20%20%20%20%20%20%20const%20int%20x%20=%200%29%5Cn%7B%5Cn%20%20%20%20for%20%28unsigned%20int%20i%20=%201;%5Cn%20%20%20%20%20%20%20%20%20i%20%3C%20v.size%28%29;%5Cn%20%20%20%20%20%20%20%20%20++i%5Cn%20%20%20%20%29%20%7B%5Cn%20%20%20%20%20%20%20%20v%5Bi%5D%20=%20%28x%20!=%200%29%20?%5Cn%20%20%20%20%20%20%20%20%20%20%5Ct%20%20%20%28v%5Bi-1%5D%2ax%29%20%3a%5Cn%20%20%20%20%20%20%5Ct%5Ct%20%20%20%28v%5Bi-1%5D%2bv%5Bi-1%5D%29;%5Cn%20%20%20%20%7D%5Cn%7D%5Cn%5Cn//%20Main%5Cnint%20main%28%29%5Cn%7B%5Cn%20%20%20%20std%3a%3avector%3Cint%3E%20v%2810,%202%29;%5Cn%20%20%20%20f1%28v%29;%5Cn%20%20%20%20return%200;%5Cn%7D%22,%22compiler%22%3a%22/usr/bin/g%2b%2b-4.8%22,%22options%22%3a%22-O3%22%7D%5D%7D" rel="nofollow">Godbolt page</a> tells me following things:</p> <p><code>#6</code>,<code>#7</code> Exit immediately if the loop won't ever be entered (<code>size()</code> &lt;= 1).</p> <p><code>#8</code>,<code>#9</code> Check if <code>x</code> is not 0, if it's true, then one loop will be chosen (<code>.L3</code> + <code>.L6</code>), otherwise second loop will be taken (<code>.L5</code>).</p> <p>As you can see two optimizations were performed including the one you were querying about.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload