<div dir="ltr">i removed printf from loop. Now getting no error. but the IR doesnot contain vectorized code. IR Output is as follows:<div><div>; ModuleID = 'sum-vec.ll'</div><div>source_filename = "sum-vec.c"</div><div>target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"</div><div>target triple = "x86_64-unknown-linux-gnu"</div><div><br></div><div>; Function Attrs: norecurse nounwind readnone uwtable</div><div>define i32 @main(i32, i8** nocapture readnone) local_unnamed_addr #0 {</div><div>  ret i32 0</div><div>}</div><div><br></div><div>attributes #0 = { norecurse nounwind readnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="knl" "target-features"="+adx,+aes,+avx,+avx2,+avx512cd,+avx512er,+avx512f,+avx512pf,+bmi,+bmi2,+cx16,+f16c,+fma,+fsgsbase,+fxsr,+lzcnt,+mmx,+movbe,+pclmul,+popcnt,+prefetchwt1,+rdrnd,+rdseed,+rtm,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt" "unsafe-fp-math"="false" "use-soft-float"="false" }</div><div><br></div><div>!llvm.ident = !{!0}</div><div><br></div><div>!0 = !{!"clang version 4.0.0 (tags/RELEASE_400/final)"}</div></div><div><br></div><div>what to do? please help.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 17, 2017 at 9:57 PM, 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">Move the printf out of the loop and it should vectorize just fine.<br></div><div class="HOEnZb"><div class="h5"><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_-9083316128729032069m_-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_-9083316128729032069m_-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>
</div></div></blockquote></div><br></div>