GCC sometimes loses alignment information. If we declare an aligned pointer type:
// These two lines work (together) typedef real aligned_real __attribute__((aligned(16))); typedef const aligned_real* SSE_PTR; Then gcc generates aligned access here: // This function uses ALIGNED accesses real f(SSE_PTR p, SSE_PTR q,int n) { real sum = 0; for(int i=0; i<n;i++) sum += p[i] * q[i]; return sum; } But not here: real f2a(const double* p_, const double* q_,int n) { SSE_PTR __restrict__ p = p_; SSE_PTR __restrict__ q = q_; real sum = 0; for(int i=0; i<n;i++) sum += p[i] * q[i]; return sum; } This could matter when the user know which things are aligned. gcc version 4.5.0 20100119 (experimental) [trunk revision 156049] (Ubuntu 20100119-0ubuntu1) gcc-4.5 -g -c test.C -O3 -ffast-math -msse3 -mtune=barcelona -ftree-vectorizer-verbose=4 -- Summary: GCC sometimes ignores information about pointer target alignment Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: bredelin at ucla dot edu GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42846