Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

-Rpass-missed=loop-vectorize says nothing at all for outer loops #28373

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR28374
Status NEW
Importance P normal
Reported by Sean McBride (sean@rogue-research.com)
Reported on 2016-06-30 14:00:55 -0700
Last modified on 2018-12-03 07:41:06 -0800
Version trunk
Hardware Macintosh MacOS X
CC anemet@apple.com, francisvm@yahoo.com, hfinkel@anl.gov, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments test.c (282 bytes, application/octet-stream)
Blocks
Blocked by
See also PR28415, PR28377
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.
Quuxplusone commented 8 years ago

Attached test.c (282 bytes, application/octet-stream): Repro case

Quuxplusone commented 8 years ago

This should be easy. Thanks again for reporting.

Quuxplusone commented 5 years ago

Just tried again with trunk 347180, issue still reproduces.