I\'m trying to get my code to auto vectorize, but it isn\'t working.
int _tmain(int argc, _TCHAR* argv[])
{
const int N = 4096;
float x[N];
float
One problem could be that your stack allocation isn't necessarily aligned by your compiler. If your compiler supports c++11 you could use:
float x[N] alignas(16);
float y[N] alignas(16);
To explicitly get 16 byte aligned memory, which is required by most SSE operations.
EDIT:
Even if alignment isn't the issue and your compiler is vectorizing unaligned code you should make this optimization as unaligned SSE operations are very slow compared to their aligned counterparts.