<div dir="ltr">Hello, <div>i am trying to vectorize a simple matrix multiplication in llvm;</div><div>here is my code;</div><div><br></div><div><div>#include <stdio.h></div><div>#define N 1000</div><div> </div><div>// This function multiplies A[][] and B[][], and stores</div><div>// the result in C[][]</div><div>void multiply(int A[][N], int B[][N], int C[][N])</div><div>{</div><div>    int i, j, k;</div><div>    for (i = 0; i < N; i++)</div><div>    {</div><div>        for (j = 0; j < N; j++)</div><div>        {</div><div>            C[i][j] = 0;</div><div>            for (k = 0; k < N; k++)</div><div>                C[i][j] += A[i][k]*B[k][j];</div><div>        }</div><div>    }</div><div>}</div></div><div><br></div><div>here are the commands;</div><div><br></div><div><br></div><div><br></div><div><div>clang  -S -emit-llvm mat.c -march=knl -O3 -mllvm -disable-llvm-optzns -o mat.ll</div></div><div><br></div><div><div>opt  -S -O3  mat.ll -o mat_o3.ll</div></div><div><br></div><div><div>llc -x86-asm-syntax=intel mat_o3.ll -o mat_intel.s</div></div><div><br></div><div><br></div><div>with this command i got the below error</div><div><div>opt  -S -O3 -force-vector-width=16 mat.ll -o mat_o3.ll</div><div><br></div><div><br></div><div>remark: <unknown>:0:0: loop not vectorized: value that could not be identified as reduction is used outside the loop</div></div><div><br></div><div><br></div><div>it is unable to vectorize the matrix multiplication and in .ll and .s files i see the scalar instructions.</div><div><br></div><div>Why is that so? What is my mistake?? Kindly correct me.</div><div><br></div><div>Looking forward to your reply</div><div><br></div><div>Thank You</div><div><br></div></div>