Dear gcc developers,

I am new to this list. 
I tried to use the auto-vectorization (4.2.1 (SUSE Linux)) but unfortunately 
with limited success.
My code is bassically a matrix library in C++. The vectorizer does not like 
the member variables. Consider this code compiled with 
gcc -ftree-vectorize -msse2 -ftree-vectorizer-verbose=5 
-funsafe-math-optimizations....
that gives basically  "not vectorized: unhandled data-ref"
<C++ code snippet>
class P{
public:
  P() : m(5),n(3) {
    double *d = data;
    for (int i=0; i<m*n; i++)
      d[i] = i/10.2;
  }
  void test(const double& sum);
private:
  int m;
  int n;
  double data[15];
};

void P::test(const double& sum) {  
  double *d = this->data;
  for(int i=0; i<m*n; i++){
    d[i]+=sum;
  }
}
</C++ code snippet>
whereas the more or less equivalent C version works just fine:
<C code snippet>
int m=5;
int n=3;
double data[15];

void test(const double& sum) {  
  int mn = m*n;
  for(int i=0; i<mn; i++){
    data[i]+=sum;
  }
}
</C code snippet>

Is there a fundamental problem in using the vectorizer in C++?

Regards!
        Georg

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to