[llvm-dev] LLVM Vectorisation Bug

Renato Golin via llvm-dev llvm-dev at lists.llvm.org
Sun Aug 6 13:43:22 PDT 2017


On 6 August 2017 at 10:49, hameeza ahmed <hahmed2305 at gmail.com> wrote:
> Thank You,
> Stencil code is attached here.

Right, that explains it: your tail loop count doesn't reach 2048 iterations:

#define N 2048
for (i = 1; i <= N-2; i++)
  for (j = 1; j <= N-2; j++)
    a[i][j] = b[i][j];

That'll be 2045 iterations.

Artificially playing with the ranges (N+1, etc) yields vector code, as expected.

Same for the main loop:

   float con=0.2;
   for (k = 0; k < N; k++) {
       for (i = 1; i <= N-2; i++)
           for (j = 1; j <= N-2; j++)
              b[i][j] = con * (a[i][j] + a[i-1][j] + a[i+1][j] +
a[i][j-1] + a[i][j+1]);

cheers,
--renato


More information about the llvm-dev mailing list