[Bug tree-optimization/92130] Missed vectorization for iteration dependent loads and simple multiplicative accumulators

witold.baryluk+gcc at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Oct 16 19:19:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92130

--- Comment #3 from Witold Baryluk <witold.baryluk+gcc at gmail dot com> ---
If only the frequency is updated in the inner loop:

    frequency *= 2.131f;

function fill_data is vectorized:

mesh_minimal.c:34:3: optimized: loop vectorized using 64 byte vectors
mesh_minimal.c:33:13: note: vectorized 1 loops in function.


However if amplitude is updated in the inner loop:

    amplitude *= 0.781f;

function fill_data is NOT vectorized.

mesh_minimal.c:34:3: missed: couldn't vectorize loop
mesh_minimal.c:34:3: missed: not vectorized: latch block not empty.
mesh_minimal.c:33:13: note: vectorized 0 loops in function.


Here for reference:


/* line 20 */ static float perlin1d(float x) {
  float accum = 0.0;
  float frequency = 1.0;
  float amplitude = 1.0;
  for (int i = 0; i < 8; i++) {
    accum += amplitude * (sinf(x * frequency + (float)i));
    frequency *= 2.131f;
    amplitude *= 0.781f;
  }
  return accum;
}

__attribute__((noinline))
/* line 33 */ static void fill_data(int width, float * __restrict__
height_data, float scale) {
  /* line 34 */ for (int i = 0; i < width; i++) {
    height_data[i] = perlin1d(i);
  }
}


More information about the Gcc-bugs mailing list