Skip to content

Instantly share code, notes, and snippets.

@marcobeltempo
Last active December 10, 2017 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcobeltempo/d8ba75deb351b4a20cab5ddb32d61a29 to your computer and use it in GitHub Desktop.
Save marcobeltempo/d8ba75deb351b4a20cab5ddb32d61a29 to your computer and use it in GitHub Desktop.
The following c loop will not enable the gcc compiler for auto-vectorization
//gcc -O3 -fopt-info-vec-missed=loop_vect_v0.miss loop_vect_v0.c -o loop_vect_v0
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int array1[1000];
int array2[1000];
long array3[1000];
long arraySum = 0;
srand(time(NULL));
for (int i = 0; i < 1000; i++) {
array1[i] = (rand()% 2001) - 1000;
array2[i] = (rand()% 2001) - 1000;
array3[i] = array1[i] + array2[i];
arraySum += array3[i];
}
printf("The total array sum is: %li\n", arraySum);
return 0;
}
loop_vect_v0.c:14:1: note: not vectorized: loop contains function calls or data references that cannot be analyzed
loop_vect_v0.c:12:1: note: not vectorized: not enough data-refs in basic block.
loop_vect_v0.c:16:22: note: not vectorized: not enough data-refs in basic block.
loop_vect_v0.c:14:1: note: not vectorized: not enough data-refs in basic block.
loop_vect_v0.c:20:9: note: not vectorized: not enough data-refs in basic block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment