<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 5 December 2016 at 12:08, Philip Pfaffe via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Dennis,<div><br></div><div>While Clang's code is significantly larger,  that is probably on purpose: Clang has vectorized the goto-loop.</div><div><br></div><div>To validate whether that was correct and a good idea, plug both results into a benchmark and look at the actual performance data.</div></div></blockquote><div><br></div><div>And that, in turn, depends on the length of the loop. If the values are known at compile-time for `count`, the compiler will know whether performing SSE operations or not "is worth it". <br><br></div><div>I had a case where I was passing an array of int and a length to a function, and clang generated a whole lot of instructions to unroll the loop and make it SSE - not realizing that the common value for `length` was 1 and never bigger than some small number (16 or 32). I didn't make any effort to imrpove the compiled code, as I realized it was relatively simple to inline the whole piece of code in LLVM-IR (it was part of my Pascal compiler project). But I believe if I had added a `assert(length < 16)` to the code, it would have done a decent job with it. [Inlining it helps my Pascal compiler beat the FreePascal implementation by about 2-3x using that particular algorithm for solving suduko - the call itself was quite an overhead, and "not having a loop when you don't need to" helps even more]<br><br>--<br></div><div>Mats<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Philip</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2016-12-05 12:32 GMT+01:00 Dennis Luehring via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">FYI<br>
<br>
found this example while reading:<br>
<a href="https://github.com/jameysharp/corrode/issues/30#issuecomment-231969365" rel="noreferrer" target="_blank">https://github.com/jameysharp/<wbr>corrode/issues/30#issuecomment<wbr>-231969365</a><br>
and compared it with current gcc 6.2, clang 3.9<br>
<br>
gcc 6.2 result is quite small - clang 3.9 produces much much more code<br>
for this example<br>
<a href="https://godbolt.org/g/uWxr8F" rel="noreferrer" target="_blank">https://godbolt.org/g/uWxr8F</a><br>
<br>
is that a missing optimization opportunity or just wrong behavior of the<br>
optimizer?<br>
<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div>