Skip to content

Instantly share code, notes, and snippets.

@marcobeltempo
Created December 10, 2017 00:51
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/39482b9da39f1c64779807bc4de4d407 to your computer and use it in GitHub Desktop.
Save marcobeltempo/39482b9da39f1c64779807bc4de4d407 to your computer and use it in GitHub Desktop.
The first loop will enable the gcc compiler to use auto-vectorization
//gcc -O3 -fopt-info-vec-missed=loop_vect_v1.miss loop_vect_v1.c -o loop_vect_v1
#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;
}
for (int i = 0; i < 1000; i++) {
array3[i] = array1[i] + array2[i];
arraySum += array3[i];
}
printf("The total array sum is: %li\n", arraySum);
return 0;
}
loop_vect_v1.c:20:1: note: step unknown.
loop_vect_v1.c:20:1: note: misalign = 0 bytes of ref array1[i_41]
loop_vect_v1.c:20:1: note: misalign = 0 bytes of ref array2[i_41]
loop_vect_v1.c:20:1: note: num. args = 4 (not unary/binary/ternary op).
loop_vect_v1.c:20:1: note: not ssa-name.
loop_vect_v1.c:20:1: note: use not simple.
loop_vect_v1.c:20:1: note: num. args = 4 (not unary/binary/ternary op).
loop_vect_v1.c:20:1: note: not ssa-name.
loop_vect_v1.c:20:1: note: use not simple.
loop_vect_v1.c:14:1: note: not vectorized: loop contains function calls or data references that cannot be analyzed
loop_vect_v1.c:12:1: note: not vectorized: not enough data-refs in basic block.
loop_vect_v1.c:16:22: note: not vectorized: not enough data-refs in basic block.
loop_vect_v1.c:14:1: note: not vectorized: not enough data-refs in basic block.
loop_vect_v1.c:21:33: note: not vectorized: no vectype for stmt: vect__9.5_17 = MEM[(int *)vectp_array1.3_32];
scalar_type: vector(4) int
loop_vect_v1.c:21:33: note: not vectorized: no vectype for stmt: vect__10.8_14 = MEM[(int *)vectp_array2.6_16];
scalar_type: vector(4) int
loop_vect_v1.c:21:33: note: not vectorized: no grouped stores in basic block.
loop_vect_v1.c:24:9: note: not vectorized: not enough data-refs in basic block.
loop_vect_v1.c:5:5: note: not vectorized: not enough data-refs in basic block.
loop_vect_v1.c:20:1: note: loop vectorized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment