Comment 9 for bug 539632

Revision history for this message
Dmitri Hrapof (hrapof) wrote : Re: [Bug 539632] Re: simd woes

Nathan Froyd пишет:
> I don't think this counts as a bug we get to fix, not even the stack
> alignment changes Nikodemus suggested (which might just paper over
> C-side problems).
Thank you for pointing me to -fPIC option!
However it doesn't seem to be the only cause of the problem.
With -fPIC and without the macro change I still get the error.

And without _mm_malloc:

void himd_sqrt (double* x, int len)
{
  double __attribute__((aligned(16))) xa[2];
  int i, l1 = len%2 ? len - 1 : len;
  for (i=0; i<l1; i+=2) {
    xa[0]=x[i];
    xa[1]=x[i+1];
    _mm_store_pd(xa, _mm_sqrt_pd(_mm_load_pd(xa)));
    x[i]=xa[0];
    x[i+1]=xa[1];
  }
  if (len%2) {
    xa[0]=x[l1];
    _mm_store_pd(xa, _mm_sqrt_pd(_mm_load_pd(xa)));
    x[l1]=xa[0];
  }
}