Autovectorization help

Nicklas Bo Jensen nbjensen@gmail.com
Thu Oct 4 12:20:00 GMT 2012


Hi,

I'm trying to use the autovectorizer in gcc 4.7.2. However I'm getting
bad data references in the .vect comments generated using
-ftree-vectorizer-verbose=, even though I have used restrict on all
arrays. Its a reference with two arrays where one array is used to
index the other: array1[array2[index]]. I don't see how this should
not be vectorizable as we only read from the arrays.

Is this not supported or is there some clever way to rewrite this?

Example:

int foo(int * restrict array1, int * restrict array2) {
  int res = 0;
  for (int i = 0; i < 50000; i++) {
    int v = array2[array1[i]]; //This gives bad data reference comment
in .vect file.
    res += v * v;
  }
  return res;
}

Thanks a lot,
Nicklas



More information about the Gcc-help mailing list