Hi! I'd like to specify (for vectorization) the alignment of the target of a pointer. I.e. I have a vector of floats that I know is suitable aligned and that get's passed to a function like
typedef ???? afloatp; void foo(afloatp __restrict__ a, afloatp __restrict__ b, afloatp __restrict__ c) { int i; for (i=0; i<4; ++i) a[i] = b[i] + c[i]; } now, the obvious typedef float __attribute__((aligned(16))) * afloatp; doesn't have any effect on (*a)s alignment, and specifying the alignment in the function argument list like void foo(float __attribute__((aligned(16))) * __restrict__ a, float __attribute__((aligned(16))) * __restrict__ b, float __attribute__((aligned(16))) * __restrict__ c) gets me simd.c:12: error: alignment may not be specified for 'a' simd.c:13: error: alignment may not be specified for 'b' simd.c:14: error: alignment may not be specified for 'c' which I find confusing. Specifying alignment of the pointer itself gets me beyond compiling but of course doesn't buy me anything (the results are similar to using the typedef). The only way I was able to convince gcc that the target of a is aligned is using *ghasp* an aligned struct like struct v4sf { float v[4]; } __attribute__((aligned(16))); void foo(struct v4sf * __restrict__ a, struct v4sf * __restrict__ b, struct v4sf * __restrict__ c) { int i; for (i=0; i<4; ++i) a->v[i] = b->v[i] + c->v[i]; } !? Is this really the only way? Is it supposed to be the only way? I remember the thread about alignment specifications for arrays and agree that float __attribute__((aligned(16))) x[4]; is ill-formed, but float x[4] __attribute__((aligned(16))); and float __attribute__((aligned(16))) *x; are not? Thanks for any suggestions, Richard. -- Richard Guenther <richard dot guenther at uni-tuebingen dot de> WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/