<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Rail,<div class=""><br class=""></div><div class="">Two hints to begin with:<div class=""><br class=""></div><div class="">1) Makes sure you example is vectorized on X86 for example<div class="">2) Is your target correctly overriding the TTI (declaring the vector register size for example) so that the vectorizer can kicks-in (see X86TTIImpl::getRegisterBitWidth for instance). Alternatively you can test the SLP vectorizer by passing to clang: -mllvm -slp-max-reg-size -mllvm 512 (I don't see an equivalent option for the loop vectorizer though).</div><div class=""><br class=""></div><div class="">-- </div><div class="">Mehdi</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 16, 2016, at 11:31 AM, Rail Shafigulin via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">My question is:</div><div class="">How do I make clang to generate assembly with vector instruction for my target?</div><div class=""><br class=""></div><div class="">The back story is:</div>I've added a few vector instructions to my target and confirmed that they are used by running my code on the test below and using a following command: <div class=""><div class=""><br class=""></div><div class=""><span style="font-size:12.8px" class="">opt i.esencia.ll -S -march=esencia -mcpu=esencia -loop-vectorize | llc -mcpu=esencia -o i.esencia.s</span><br class=""></div><div class=""><br class=""></div><div class=""><div class="">target datalayout = "E-m:e-p:32:32-i64:32-f64:32-v64:32-v128:32-a:0:32-n32"</div><div class="">target triple = "esencia"</div><div class=""><br class=""></div><div class="">; Function Attrs: nounwind uwtable</div><div class="">define i32 @main() {</div><div class="">entry:</div><div class=""> %z = alloca <4 x i32></div><div class=""> %a = alloca <4 x i32></div><div class=""> %b = alloca <4 x i32></div><div class=""> %a.l = load <4 x i32>* %a</div><div class=""> %b.l = load <4 x i32>* %b</div><div class=""> %z.l = add <4 x i32> %a.l, %b.l</div><div class=""> store <4 x i32> %z.l, <4 x i32>* %z</div><div class=""> ret i32 0</div><div class="">}</div></div><div class=""><br class=""></div><div class="">Now I'm trying to run clang and vectorize the following test:</div><div class=""><br class=""></div><div class=""><div class="">#define N 16</div><div class=""><br class=""></div><div class="">int main () {</div><div class=""><br class=""></div><div class=""> int a[N], b[N];</div><div class=""> int c[N];</div><div class=""><br class=""></div><div class=""> for (int i = 0; i < N; ++i)</div><div class=""> c[i] = a[i] + b[i];</div><div class=""><br class=""></div><div class=""> int sum=0;</div><div class=""> for (int i = 0; i < N; ++i)</div><div class=""> sum += c[i];</div><div class=""><br class=""></div><div class=""> return sum;</div><div class="">}</div></div><div class=""><br class=""></div><div class="">Here are the command lines I tried:</div><div class=""><br class=""></div><div class="">clang -S test.c --target=esencia -fvectorize -o test.esencia.s<br class=""></div><div class=""><br class=""></div><div class="">clang -S test.c --target=esencia -fvectorize -fslp-vectorize-aggressive -o test.esencia.s -fslp-vectorize<br class=""></div><div class=""><br class=""></div><div class="">clang -S test.c --target=esencia -fvectorize -fslp-vectorize-aggressive -o test.esencia.s -fslp-vectorize -fno-lax-vector-conversions<br class=""></div><div class=""><br class=""></div><div class="">Unfortunately nothing worked. Can someone help me out? I can't really figure out why this is not working.</div><div class=""><br class=""></div><div class="">Any help is appreciated.</div><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">Rail Shafigulin<br class=""></div>Software Engineer <br class="">Esencia Technologies<br class=""></div></div></div></div>
</div></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></div></div></body></html>