<div dir="ltr"><div>My question is:</div><div>How do I make clang to generate assembly with vector instruction for my target?</div><div><br></div><div>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><div><br></div><div><span style="font-size:12.8px">opt i.esencia.ll -S -march=esencia -mcpu=esencia -loop-vectorize | llc -mcpu=esencia -o i.esencia.s</span><br></div><div><br></div><div><div>target datalayout = "E-m:e-p:32:32-i64:32-f64:32-v64:32-v128:32-a:0:32-n32"</div><div>target triple = "esencia"</div><div><br></div><div>; Function Attrs: nounwind uwtable</div><div>define i32 @main() {</div><div>entry:</div><div>   %z = alloca <4 x i32></div><div>   %a = alloca <4 x i32></div><div>   %b = alloca <4 x i32></div><div>   %a.l = load <4 x i32>* %a</div><div>   %b.l = load <4 x i32>* %b</div><div>   %z.l = add <4 x i32> %a.l, %b.l</div><div>   store <4 x i32> %z.l, <4 x i32>* %z</div><div>   ret i32 0</div><div>}</div></div><div><br></div><div>Now I'm trying to run clang and vectorize the following test:</div><div><br></div><div><div>#define N 16</div><div><br></div><div>int main () {</div><div><br></div><div>  int  a[N], b[N];</div><div>  int c[N];</div><div><br></div><div>  for (int i = 0; i < N; ++i)</div><div>       c[i] = a[i] + b[i];</div><div><br></div><div>  int sum=0;</div><div>  for (int i = 0; i < N; ++i)</div><div>       sum += c[i];</div><div><br></div><div>  return sum;</div><div>}</div></div><div><br></div><div>Here are the command lines I tried:</div><div><br></div><div>clang -S test.c --target=esencia -fvectorize -o test.esencia.s<br></div><div><br></div><div>clang -S test.c --target=esencia -fvectorize -fslp-vectorize-aggressive -o test.esencia.s -fslp-vectorize<br></div><div><br></div><div>clang -S test.c --target=esencia -fvectorize -fslp-vectorize-aggressive -o test.esencia.s -fslp-vectorize -fno-lax-vector-conversions<br></div><div><br></div><div>Unfortunately nothing worked. Can someone help me out? I can't really figure out why this is not working.</div><div><br></div><div>Any help is appreciated.</div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Rail Shafigulin<br></div>Software Engineer <br>Esencia Technologies<br></div></div></div></div>
</div></div>