This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 16 byte alignment hint for sse vectorization


On Nov 4, 2006, at 11:00 AM, Michael James wrote:
Does anyone have a suggestion?

#define SSE __attribute__((aligned (16)))


typedef float matrix_sub_t[1024] SSE;
typedef matrix_sub_t matrix_t[100];

matrix_t a, b, c;

void calc(matrix_sub_t * restrict ap,
          matrix_sub_t * restrict bp,
          matrix_sub_t * restrict cp) {
  int i, n = 1024;

  for (i=0; i<n; ++i) {
    ap[0][i] = bp[0][i] / (bp[0][i] + cp[0][i]);
  }
}

int main(void) {
  int i, n = 100;
  for (i=0; i<n; ++i) {
    calc(&a[i], &b[i], &c[i]);
  }
}

would seem the be one way to do this that should work. Doesn't seem to vectorize for me, though, if I read that right, the alignment issue isn't the problem but rather the data dependancy analysis:

t.c:13: note: === vect_analyze_dependences ===
t.c:13: note: not vectorized: can't determine dependence between (*bp_12)[i_4] and (*ap_16)[i_4]
t.c:13: note: bad data dependence.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]