[LLVMdev] Loop vectorizer behaviour for 2D arrays and parallel annotation

Tobias Grosser
Wed, 17 Apr 2013 06:08:05 -0000

On 04/17/2013 04:55 AM, Anadi Mishra wrote:
> Hello,
>
> I am trying to vectorize the following loop but the vectorizer says:
> "Found a possible write-write reorder" and does not vectorize.
> Why?

To my knowledge, the dependence analysis in the loop vectorizer is not
yet able to prove the absence of dependences here.

> for (j=0; j < 8; j++)
>    {
>      jj = j << 3;
>      m2[j][0] = diff[jj  ] + diff[jj+4];
>      m2[j][1] = diff[jj+1] + diff[jj+5];
>      m2[j][2] = diff[jj+2] + diff[jj+6];
>      m2[j][3] = diff[jj+3] + diff[jj+7];
>      m2[j][4] = diff[jj  ] - diff[jj+4];
>      m2[j][5] = diff[jj+1] - diff[jj+5];
>      m2[j][6] = diff[jj+2] - diff[jj+6];
>      m2[j][7] = diff[jj+3] - diff[jj+7];
>    }
>
>
> Another question is regarding the isannotatedparallel() check. Is
> there a way to make clang (or any other frontend) to generate parallel
> annotated IR?

Did you try to put '#pragma ivdep' before the loop.

Tobias

P.S.: Please attach a full C file as test case. The way the different
data structures are declared my influence the analysis.