<div dir="ltr">Move the printf out of the loop and it should vectorize just fine.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 17, 2017 at 6:52 PM, hameeza ahmed <span dir="ltr"><<a href="mailto:hahmed2305@gmail.com" target="_blank">hahmed2305@gmail.com</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">I want to vectorize the user given inputs. when opt does vectorization user supplied inputs (from a text file) will be added using AVX vector instructions.<div><br></div><div>as you pointed; When i changed my code to following:</div><div><br></div><div><div>int main(int argc, char** argv) {</div><div>int a[1000], b[1000], c[1000];</div><div>int aa=atoi(argv[1]), bb=atoi(argv[2]);</div><div>for (int i=0; i<1000; i++) {</div><div>a[i]=aa, b[i]=bb;</div><div> c[i]=a[i] + b[i];</div><div>printf("sum: %d\n", c[i]);</div><div><br></div><div>}</div></div><div><br></div><div>I am getting error remark: <unknown>:0:0: loop not vectorized: call instruction cannot be vectorized.</div><div><br></div><div>I am running following commands:</div><div>clang  -S -emit-llvm sum-vec.c -march=knl -O3 -mllvm -disable-llvm-optzns -o sum-vec.ll<br></div><div>opt  -S -O3 -force-vector-width=64 sum-vec.ll -o sum-vec03.ll<br></div><div><br></div><div>How to achieve this? Please help.</div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 17, 2017 at 10:44 AM, Nemanja Ivanovic <span dir="ltr"><<a href="mailto:nemanja.i.ibm@gmail.com" target="_blank">nemanja.i.ibm@gmail.com</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">I'm not sure what you expect to have vectorized here. If you look at the emitted code, there's no loop. It's just an add and a multiply as you might expect when adding a loop-invariant sum 1000 times in a loop.<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-5426776120835238504h5">On Wed, Aug 16, 2017 at 11:38 PM, hameeza ahmed 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></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-5426776120835238504h5"><div dir="ltr">Hello, <div>I have written the following code. when i try to vectorize it through opt. i am not getting vectorized instructions.</div><div><br></div><div><div>#include <stdio.h></div><div>#include<stdlib.h></div><div>int main(int argc, char** argv) {</div><div>int sum=0; int a=atoi(argv[1]); int b=atoi(argv[2]);</div><div>for (int i=0;i<1000;i++)</div><div>{</div><div>sum+=a+b;<br></div><div>}</div><div><br></div><div>printf("sum: %d\n", sum);</div><div>return 0;</div><div>}</div></div><div>i use following commands:</div><div><div>clang  -S -emit-llvm sum-main.c -march=knl -O3 -mllvm -disable-llvm-optzns -o sum-main.ll</div></div><div><div>opt  -S -O3 -force-vector-width=64 sum-main.ll -o sum-main03.ll</div></div><div><br></div><div>why is that so? where am i doing mistake? i am not getting vectorized operations rather getting scalar operations.</div><div><br></div><div>Please help.</div><div><br></div><div>Thank You</div><div><br></div><div>Regards</div><div><br></div></div>
<br></div></div>______________________________<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>
<br></blockquote></div><br></div>
</blockquote></div><br></div>
</blockquote></div><br></div>