Created
December 10, 2017 00:55
-
-
Save marcobeltempo/013e1daf5550138c72973962c8c5fa43 to your computer and use it in GitHub Desktop.
The second loop will enable the gcc compiler to use 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_v2.miss loop_vect_v2.c -o loop_vect_v2 | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#define MAX_ARRAY_SIZE 1000 | |
int main() { | |
int* array1 = calloc(MAX_ARRAY_SIZE,sizeof(int)); | |
int* array2 = calloc(MAX_ARRAY_SIZE,sizeof(int)); | |
long* array3 = calloc(MAX_ARRAY_SIZE,sizeof(long)); | |
long arraySum = 0; | |
srand(time(NULL)); | |
for (int i = 0; i < MAX_ARRAY_SIZE; i++) { | |
array1[i] = (rand()% 2001) - 1000; | |
array2[i] = (rand()% 2001) - 1000; | |
} | |
for (int i = 0; i < MAX_ARRAY_SIZE; i++) { | |
array3[i] = array1[i] + array2[i]; | |
arraySum += array3[i]; | |
} | |
printf("The total array sum is: %li\n", arraySum); | |
free(array1); | |
free(array2); | |
free(array3); | |
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_v2.c:22:1: note: step unknown. | |
loop_vect_v2.c:22:1: note: Unknown misalignment, naturally aligned | |
loop_vect_v2.c:22:1: note: Unknown misalignment, naturally aligned | |
loop_vect_v2.c:22:1: note: Unknown misalignment, naturally aligned | |
loop_vect_v2.c:22:1: note: not ssa-name. | |
loop_vect_v2.c:22:1: note: use not simple. | |
loop_vect_v2.c:22:1: note: not ssa-name. | |
loop_vect_v2.c:22:1: note: use not simple. | |
loop_vect_v2.c:22:1: note: not ssa-name. | |
loop_vect_v2.c:22:1: note: use not simple. | |
loop_vect_v2.c:22:1: note: not ssa-name. | |
loop_vect_v2.c:22:1: note: use not simple. | |
loop_vect_v2.c:16:1: note: not vectorized: loop contains function calls or data references that cannot be analyzed | |
loop_vect_v2.c:14:1: note: not vectorized: not enough data-refs in basic block. | |
loop_vect_v2.c:19:16: note: not vectorized: not enough data-refs in basic block. | |
loop_vect_v2.c:16:1: note: not vectorized: not enough data-refs in basic block. | |
loop_vect_v2.c:16:1: note: not vectorized: not enough data-refs in basic block. | |
loop_vect_v2.c:22:38: note: not consecutive access *_28 = _27; | |
loop_vect_v2.c:22:38: note: not consecutive access _54 = *_55; | |
loop_vect_v2.c:22:38: note: not consecutive access _52 = *_53; | |
loop_vect_v2.c:22:38: note: not vectorized: no grouped stores in basic block. | |
loop_vect_v2.c:22:38: note: not vectorized: not enough data-refs in basic block. | |
loop_vect_v2.c:24:12: note: not vectorized: no vectype for stmt: vect__16.13_124 = MEM[(int *)vectp_array1.11_122]; | |
scalar_type: vector(4) int | |
loop_vect_v2.c:24:12: note: not vectorized: no vectype for stmt: vect__19.16_129 = MEM[(int *)vectp_array2.14_127]; | |
scalar_type: vector(4) int | |
loop_vect_v2.c:24:12: note: not vectorized: no vectype for stmt: MEM[(long int *)vectp_array3.19_135] = vect__23.18_131; | |
scalar_type: vector(2) long int | |
loop_vect_v2.c:24:12: note: not vectorized: no vectype for stmt: MEM[(long int *)vectp_array3.19_138] = vect__23.18_132; | |
scalar_type: vector(2) long int | |
loop_vect_v2.c:24:12: note: not vectorized: no grouped stores in basic block. | |
loop_vect_v2.c:24:12: note: not vectorized: not enough data-refs in basic block. | |
loop_vect_v2.c:22:1: note: not consecutive access *_20 = _21; | |
loop_vect_v2.c:22:1: note: not consecutive access _14 = *_13; | |
loop_vect_v2.c:22:1: note: not consecutive access _16 = *_15; | |
loop_vect_v2.c:22:1: note: not vectorized: no grouped stores in basic block. | |
loop_vect_v2.c:22:1: note: not consecutive access *_152 = _153; | |
loop_vect_v2.c:22:1: note: not consecutive access _147 = *_42; | |
loop_vect_v2.c:22:1: note: not consecutive access _149 = *_148; | |
loop_vect_v2.c:22:1: note: not vectorized: no grouped stores in basic block. | |
loop_vect_v2.c:22:38: note: not consecutive access *_105 = _106; | |
loop_vect_v2.c:22:38: note: not consecutive access _100 = *_99; | |
loop_vect_v2.c:22:38: note: not consecutive access _102 = *_101; | |
loop_vect_v2.c:22:38: note: not vectorized: no grouped stores in basic block. | |
loop_vect_v2.c:32:1: note: not vectorized: not enough data-refs in basic block. |
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_v2.c:22:1: note: loop vectorized | |
loop_vect_v2.c:22:1: note: loop turned into non-loop; it never loops. | |
loop_vect_v2.c:22:1: note: loop with 3 iterations completely unrolled | |
loop_vect_v2.c:7:5: note: loop turned into non-loop; it never loops |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment