Created attachment 16662
Repro case
Consider:
--------test.c-------
#include <stdio.h>
int foo(int *A, int *B, int n) {
#pragma clang loop vectorize(enable)
for (int k = 0; k < n; ++k)
{
unsigned sum = 0;
#pragma clang loop vectorize(enable)
for (int i = 0; i < n; ++i)
sum += A[i] + 5;
printf("%i", sum);
}
return 0;
}
---------------
$ clang --version
clang version 3.9.0 (trunk 274259)
$ clang -S -fvectorize -O3 -Rpass=loop-vectorize -Rpass-missed=loop-vectorize -
Rpass-analysis=loop-vectorize ~/Desktop/test.c
/Users/sean/Desktop/test.c:11:4: remark: vectorized loop (vectorization width:
4, interleaved count: 2) [-Rpass=loop-vectorize]
for (int i = 0; i < n; ++i)
^
It helpfully says it vectorized the inner loop, but says *nothing* about the
outer loop (despite the #pragma even).
Adam Nemet said on cfe-dev that "the vectorizer does not visit outer loops and
the diagnostics is emitted in the vectorizer so we don’t get a chance to report
anything."
For a user trying to audit/tweak his loops to be vectorization-friendly, it's
frustrating that the flags that are supposed to report if/why a loop has/has
not been vectorized are not behaving reliably.
test.c
(282 bytes, application/octet-stream)