<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[Software is Crap]]></provider_name><provider_url><![CDATA[https://davmac.wordpress.com]]></provider_url><author_name><![CDATA[davmac]]></author_name><author_url><![CDATA[https://davmac.wordpress.com/author/davmac/]]></author_url><title><![CDATA[Updated C compiler benchmarks: llvm-2.7,&nbsp;libfirm-1.18.1]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>Since I did my <a href="https://davmac.wordpress.com/2009/04/28/c-compiler-benchmarks/">previous C compiler benchmark</a>, there have been a few new software releases, including Gcc 4.5, llvm 2.7 (and 2.6) and libfirm 1.18 (and 1.17). Here are results from benchmarking these compilers:</p>
<p><a href="https://davmac.files.wordpress.com/2010/07/c-compiler-benchmark2.png"><img data-attachment-id="137" data-permalink="https://davmac.wordpress.com/2010/07/11/updated-c-compiler-benchmarks-llvm-2-7-libfirm-1-18-1/c-compiler-benchmark2-2/" data-orig-file="https://davmac.files.wordpress.com/2010/07/c-compiler-benchmark2.png?w=450&#038;h=620" data-orig-size="450,620" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}" data-image-title="c-compiler-benchmark2" data-image-description="" data-medium-file="https://davmac.files.wordpress.com/2010/07/c-compiler-benchmark2.png?w=450&#038;h=620?w=218" data-large-file="https://davmac.files.wordpress.com/2010/07/c-compiler-benchmark2.png?w=450&#038;h=620?w=450" class="alignnone size-full wp-image-137" title="c-compiler-benchmark2" src="https://davmac.files.wordpress.com/2010/07/c-compiler-benchmark2.png?w=450&#038;h=620" alt="" width="450" height="620" srcset="https://davmac.files.wordpress.com/2010/07/c-compiler-benchmark2.png 450w, https://davmac.files.wordpress.com/2010/07/c-compiler-benchmark2.png?w=109&amp;h=150 109w, https://davmac.files.wordpress.com/2010/07/c-compiler-benchmark2.png?w=218&amp;h=300 218w" sizes="(max-width: 450px) 100vw, 450px" /><br />
</a></p>
<p>Most important things: Gcc version is now 4.4.4, though this hasn&#8217;t made much difference to the results. llvm-2.7 is benchmarked both with the &#8220;native&#8221; clang frontend, and the gcc-4.2 based frontend; note the difference in bm1, 3 and 6.</p>
<p>In the case of LLVM, results have improved significantly in bm2 and bm5.</p>
<p>For LibFirm, results have improved dramatically for bm5, but are also significantly worse for bm3.</p>
<p>Gcc is still (subjectively) the overall winner, though it does get beaten in a few of the benchmarks (bm2,6,7) by LLVM and even in a couple (bm5,7) by LibFirm.</p>
<p>Gcc 4.5 has been released but has yet to be benchmarked. <em>Edit 13/7/2010: Gcc 4.5 benchmarked, and the results are so similar to those for Gcc 4.4.4 that it&#8217;s not worth reporting them separately.</em></p>
<p>There are three new tests:</p>
<p><strong>bm8</strong> tests the compiler&#8217;s ability to remove trivial loops (loops with empty bodies, but a large number of iterations). The loops are implemented with &#8220;goto&#8221; rather than a C loop structure, and there is an inner and outer loop. No tested compiler manages to  remove the loops.</p>
<p><strong>bm9 </strong>tests the compiler&#8217;s ability to break up a loop into two separate loops, when doing so avoids an efficiency problem caused by a potential aliasing pointer. The function in the benchmark takes two arguments: an int array and an int pointer &#8220;p&#8221;. The inner part of the loop uses the value pointed at by &#8220;p&#8221; as part of an expression assigned to each array element in turn. Because &#8220;p&#8221; might alias one of the array elements, the stored value must be re-loaded each iteration, unless the compiler breaks the loop into two. None of the tested compilers perform this optimization.</p>
<p><strong>bm10 </strong>tests that a shift-left of a value inside a large loop can be reduced to a constant (due to having shifted all the bits out). None of the tested compilers manage this.</p>
<p>It&#8217;s disappointing that some optimizations which potentially yield huge benefit are not implemented in any of the tested free compilers; however, GCC 4.5 has been released and is yet to be tested <em>(edit 13/7/2010: tested, no surprises)</em>. Also, GCC includes some options for loop optimization which are not turned on at any optimization level, due to them requiring external libraries at build time; it would be interesting to see whether these would make any difference in any of the tests <em>(13/7/2010. They don&#8217;t)</em>.</p>
<p><strong>Further update 4/8/2010</strong>: I&#8217;ve just tested with gcc 4.5.1. No very noticable differences were seen from the performance of 4.4.4, however, I am running a new kernel and this seems to slightly affect the numbers for 4.4.4; for instance, bm3 comes down to about the 0.162 mark, more-or-less even with LLVM.</p>
]]></html><thumbnail_url><![CDATA[https://davmac.files.wordpress.com/2010/07/c-compiler-benchmark2.png?fit=440%2C330]]></thumbnail_url><thumbnail_width><![CDATA[240]]></thumbnail_width><thumbnail_height><![CDATA[330]]></thumbnail_height></oembed>