mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-02 21:11:12 -06:00
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;
|
|
}
|