Last active
December 10, 2017 00:50
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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