Diagnostic 15421: loop was not vectorized: memory reference is not naturally aligned ​

Cause:

This diagnostic is specific to Intel(R) Xeon Phi(TM) Coprocessor. ABI document states that the individual data element needs to be naturally aligned. Point to the ABI document too. In this example, because of the use of pack pragma, the layout of double array b is misaligned. On a classic architecture, this is a performance problem but on Intel(R) Xeon Phi(TM) coprocessor this is a stability problem since it breaks the ABI. That's why the vectorizer refuses to vectorize this loop. 

Example:
 

#pragma pack(push, 1) 

struct foo {

float a;

double b[1000];

};

#pragma pack(pop)

void bar(struct foo *p){

int i;

for (i=0;i<1000;i++){

p->b[i] = i;

}

}


$ icc example65.c -mmic -vec-report2 -c
example65.c(12): (col. 5) remark: loop was not vectorized: memory reference is not naturally aligned