You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
330 B
C++
13 lines
330 B
C++
// Compile with -O3 to see autovectorization
|
|
int testFunction(int* input, int length) {
|
|
#if __GNUC_MINOR__ >= 7
|
|
// gcc 4.7 allows us to tell it about alignments.
|
|
input = static_cast<int*>(__builtin_assume_aligned(input, 16));
|
|
#endif
|
|
int sum = 0;
|
|
for (int i = 0; i < length; ++i) {
|
|
sum += input[i];
|
|
}
|
|
return sum;
|
|
}
|