<div dir="ltr">These look like really awesome results :)<div><br></div><div style>I am using clang/LLVM to JIT some code and intuitively our workloads should benefit a lot from vectorization. Is there a way to use apply this optimization to JIT generated code?</div>
<div style><br></div><div style>Regards,</div><div style>-- Priyendra</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 4, 2013 at 8:26 PM, Nadav Rotem <span dir="ltr"><<a href="mailto:nrotem@apple.com" target="_blank">nrotem@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I would like to start a discussion about enabling the loop vectorizer by default for -Os. The loop vectorizer can accelerate many workloads and enabling it for -Os and -O2 has obvious performance benefits. At the same time the loop vectorizer can increase the code size because of two reasons. First, to vectorize some loops we have to keep the original loop around in order to handle the last few iterations.  Second, on x86 and possibly other targets, the encoding of vector instructions takes more space.<br>

<br>
The loop vectorizer is already aware of the ‘optsize’ attribute and it does not vectorize loops which require that we keep the scalar tail. It also does not unroll loops when optimizing for size. It is not obvious but there are many cases in which this conservative kind of vectorization is profitable.  The loop vectorizer does not try to estimate the encoding size of instructions and this is one reason for code growth.<br>

<br>
I measured the effects of vectorization on performance and binary size using -Os. I measured the performance on a Sandybridge and compiled our test suite using -mavx -f(no)-vectorize -Os.  As you can see in the attached data there are many workloads that benefit from vectorization.  Not as much as vectorizing with -O3, but still a good number of programs.  At the same time the code growth is minimal.  Most workloads are unaffected and the total code growth for the entire test suite is 0.89%.  Almost all of the code growth comes from the TSVC test suite which contains a large number of large vectorizable loops.  I did not measure the compile time in this batch but I expect to see an increase in compile time in vectorizable loops because of the time we spend in codegen.<br>

<br>
I am interested in hearing more opinions and discussing more measurements by other people.<br>
<br>
Nadav<br>
<br>
<br>
. <br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>